Source: api/api/security.js

  1. /*
  2. * Copyright OpenSearch Contributors
  3. * SPDX-License-Identifier: Apache-2.0
  4. *
  5. * The OpenSearch Contributors require contributions made to
  6. * this file be licensed under the Apache-2.0 license or a
  7. * compatible open source license.
  8. *
  9. */
  10. 'use strict';
  11. /** @namespace API-Security */
  12. /* eslint camelcase: 0 */
  13. /* eslint no-unused-vars: 0 */
  14. const {
  15. handleError,
  16. snakeCaseKeys,
  17. encodePathParam,
  18. normalizeArguments,
  19. kConfigurationError,
  20. } = require('../utils');
  21. const snakeCase = {};
  22. function SecurityApi(transport, ConfigurationError) {
  23. this.transport = transport;
  24. this[kConfigurationError] = ConfigurationError;
  25. }
  26. /**
  27. * Changes the password for the current user.
  28. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#change-password - Security - Change Password}
  29. *
  30. * @memberOf API-Security
  31. *
  32. * @param {Object} params
  33. * @param {Object} params.body
  34. *
  35. * @param {Object} options - Options for {@link Transport#request}
  36. * @param {function} callback - Callback that handles errors and response
  37. *
  38. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  39. */
  40. SecurityApi.prototype.changePassword = function securityChangePasswordApi(
  41. params,
  42. options,
  43. callback
  44. ) {
  45. [params, options, callback] = normalizeArguments(params, options, callback);
  46. if (params.body == null) {
  47. const err = new this[kConfigurationError]('Missing required parameter: body');
  48. return handleError(err, callback);
  49. }
  50. let { method, body, ...querystring } = params;
  51. let path = ['', '_plugins', '_security', 'api', 'account'].filter((c) => c != null).join('/');
  52. method = method || 'PUT';
  53. body = body || '';
  54. querystring = snakeCaseKeys(null, snakeCase, querystring);
  55. return this.transport.request({ method, path, body, querystring }, options, callback);
  56. };
  57. /**
  58. * Creates or replaces the specified action group.
  59. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#create-action-group - Security - Create Action Group}
  60. *
  61. * @memberOf API-Security
  62. *
  63. * @param {Object} params
  64. * @param {string} params.action_group - The name of the action group to create or replace
  65. * @param {Object} params.body
  66. *
  67. * @param {Object} options - Options for {@link Transport#request}
  68. * @param {function} callback - Callback that handles errors and response
  69. *
  70. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  71. */
  72. SecurityApi.prototype.createActionGroup = function securityCreateActionGroupApi(
  73. params,
  74. options,
  75. callback
  76. ) {
  77. [params, options, callback] = normalizeArguments(params, options, callback);
  78. if (params.actionGroup == null && params.action_group == null) {
  79. const err = new this[kConfigurationError]('Missing required parameter: action_group');
  80. return handleError(err, callback);
  81. }
  82. if (params.body == null) {
  83. const err = new this[kConfigurationError]('Missing required parameter: body');
  84. return handleError(err, callback);
  85. }
  86. let { method, body, actionGroup, action_group, ...querystring } = params;
  87. action_group = encodePathParam(actionGroup, action_group);
  88. let path = ['', '_plugins', '_security', 'api', 'actiongroups', action_group]
  89. .filter((c) => c != null)
  90. .join('/');
  91. method = method || 'PUT';
  92. body = body || '';
  93. querystring = snakeCaseKeys(null, snakeCase, querystring);
  94. return this.transport.request({ method, path, body, querystring }, options, callback);
  95. };
  96. /**
  97. * Creates or replaces the specified role.
  98. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#create-role - Security - Create Role}
  99. *
  100. * @memberOf API-Security
  101. *
  102. * @param {Object} params
  103. * @param {string} params.role
  104. * @param {Object} params.body
  105. *
  106. * @param {Object} options - Options for {@link Transport#request}
  107. * @param {function} callback - Callback that handles errors and response
  108. *
  109. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  110. */
  111. SecurityApi.prototype.createRole = function securityCreateRoleApi(params, options, callback) {
  112. [params, options, callback] = normalizeArguments(params, options, callback);
  113. if (params.role == null) {
  114. const err = new this[kConfigurationError]('Missing required parameter: role');
  115. return handleError(err, callback);
  116. }
  117. if (params.body == null) {
  118. const err = new this[kConfigurationError]('Missing required parameter: body');
  119. return handleError(err, callback);
  120. }
  121. let { method, body, role, ...querystring } = params;
  122. role = encodePathParam(role);
  123. let path = ['', '_plugins', '_security', 'api', 'roles', role].filter((c) => c != null).join('/');
  124. method = method || 'PUT';
  125. body = body || '';
  126. querystring = snakeCaseKeys(null, snakeCase, querystring);
  127. return this.transport.request({ method, path, body, querystring }, options, callback);
  128. };
  129. /**
  130. * Creates or replaces the specified role mapping.
  131. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#create-role-mapping - Security - Create Role Mapping}
  132. *
  133. * @memberOf API-Security
  134. *
  135. * @param {Object} params
  136. * @param {string} params.role
  137. * @param {Object} params.body
  138. *
  139. * @param {Object} options - Options for {@link Transport#request}
  140. * @param {function} callback - Callback that handles errors and response
  141. *
  142. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  143. */
  144. SecurityApi.prototype.createRoleMapping = function securityCreateRoleMappingApi(
  145. params,
  146. options,
  147. callback
  148. ) {
  149. [params, options, callback] = normalizeArguments(params, options, callback);
  150. if (params.role == null) {
  151. const err = new this[kConfigurationError]('Missing required parameter: role');
  152. return handleError(err, callback);
  153. }
  154. if (params.body == null) {
  155. const err = new this[kConfigurationError]('Missing required parameter: body');
  156. return handleError(err, callback);
  157. }
  158. let { method, body, role, ...querystring } = params;
  159. role = encodePathParam(role);
  160. let path = ['', '_plugins', '_security', 'api', 'rolesmapping', role]
  161. .filter((c) => c != null)
  162. .join('/');
  163. method = method || 'PUT';
  164. body = body || '';
  165. querystring = snakeCaseKeys(null, snakeCase, querystring);
  166. return this.transport.request({ method, path, body, querystring }, options, callback);
  167. };
  168. /**
  169. * Creates or replaces the specified tenant.
  170. * <br/> See Also: {@link https://opensearch.org/docs/2.7/security/access-control/api/#create-tenant - Security - Create Tenant}
  171. *
  172. * @memberOf API-Security
  173. *
  174. * @param {Object} params
  175. * @param {string} params.tenant
  176. * @param {Object} params.body
  177. *
  178. * @param {Object} options - Options for {@link Transport#request}
  179. * @param {function} callback - Callback that handles errors and response
  180. *
  181. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  182. */
  183. SecurityApi.prototype.createTenant = function securityCreateTenantApi(params, options, callback) {
  184. [params, options, callback] = normalizeArguments(params, options, callback);
  185. if (params.tenant == null) {
  186. const err = new this[kConfigurationError]('Missing required parameter: tenant');
  187. return handleError(err, callback);
  188. }
  189. if (params.body == null) {
  190. const err = new this[kConfigurationError]('Missing required parameter: body');
  191. return handleError(err, callback);
  192. }
  193. let { method, body, tenant, ...querystring } = params;
  194. tenant = encodePathParam(tenant);
  195. let path = ['', '_plugins', '_security', 'api', 'tenants', tenant]
  196. .filter((c) => c != null)
  197. .join('/');
  198. method = method || 'PUT';
  199. body = body || '';
  200. querystring = snakeCaseKeys(null, snakeCase, querystring);
  201. return this.transport.request({ method, path, body, querystring }, options, callback);
  202. };
  203. /**
  204. * Creates or replaces the specified user.
  205. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#create-user - Security - Create User}
  206. *
  207. * @memberOf API-Security
  208. *
  209. * @param {Object} params
  210. * @param {string} params.username
  211. * @param {Object} params.body
  212. *
  213. * @param {Object} options - Options for {@link Transport#request}
  214. * @param {function} callback - Callback that handles errors and response
  215. *
  216. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  217. */
  218. SecurityApi.prototype.createUser = function securityCreateUserApi(params, options, callback) {
  219. [params, options, callback] = normalizeArguments(params, options, callback);
  220. if (params.username == null) {
  221. const err = new this[kConfigurationError]('Missing required parameter: username');
  222. return handleError(err, callback);
  223. }
  224. if (params.body == null) {
  225. const err = new this[kConfigurationError]('Missing required parameter: body');
  226. return handleError(err, callback);
  227. }
  228. let { method, body, username, ...querystring } = params;
  229. username = encodePathParam(username);
  230. let path = ['', '_plugins', '_security', 'api', 'internalusers', username]
  231. .filter((c) => c != null)
  232. .join('/');
  233. method = method || 'PUT';
  234. body = body || '';
  235. querystring = snakeCaseKeys(null, snakeCase, querystring);
  236. return this.transport.request({ method, path, body, querystring }, options, callback);
  237. };
  238. /**
  239. * Delete a specified action group.
  240. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#delete-action-group - Security - Delete Action Group}
  241. *
  242. * @memberOf API-Security
  243. *
  244. * @param {Object} params
  245. * @param {string} params.action_group - Action group to delete.
  246. *
  247. * @param {Object} options - Options for {@link Transport#request}
  248. * @param {function} callback - Callback that handles errors and response
  249. *
  250. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  251. */
  252. SecurityApi.prototype.deleteActionGroup = function securityDeleteActionGroupApi(
  253. params,
  254. options,
  255. callback
  256. ) {
  257. [params, options, callback] = normalizeArguments(params, options, callback);
  258. if (params.actionGroup == null && params.action_group == null) {
  259. const err = new this[kConfigurationError]('Missing required parameter: action_group');
  260. return handleError(err, callback);
  261. }
  262. let { method, body, actionGroup, action_group, ...querystring } = params;
  263. action_group = encodePathParam(actionGroup, action_group);
  264. let path = ['', '_plugins', '_security', 'api', 'actiongroups', action_group]
  265. .filter((c) => c != null)
  266. .join('/');
  267. method = method || 'DELETE';
  268. body = body || '';
  269. querystring = snakeCaseKeys(null, snakeCase, querystring);
  270. return this.transport.request({ method, path, body, querystring }, options, callback);
  271. };
  272. /**
  273. * Deletes all distinguished names in the specified cluster’s or node’s allow list.
  274. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#delete-distinguished-names - Security - Delete Distinguished Names}
  275. *
  276. * @memberOf API-Security
  277. *
  278. * @param {Object} params
  279. * @param {string} params.cluster_name
  280. *
  281. * @param {Object} options - Options for {@link Transport#request}
  282. * @param {function} callback - Callback that handles errors and response
  283. *
  284. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  285. */
  286. SecurityApi.prototype.deleteDistinguishedNames = function securityDeleteDistinguishedNamesApi(
  287. params,
  288. options,
  289. callback
  290. ) {
  291. [params, options, callback] = normalizeArguments(params, options, callback);
  292. if (params.clusterName == null && params.cluster_name == null) {
  293. const err = new this[kConfigurationError]('Missing required parameter: cluster_name');
  294. return handleError(err, callback);
  295. }
  296. let { method, body, clusterName, cluster_name, ...querystring } = params;
  297. cluster_name = encodePathParam(clusterName, cluster_name);
  298. let path = ['', '_plugins', '_security', 'api', 'nodesdn', cluster_name]
  299. .filter((c) => c != null)
  300. .join('/');
  301. method = method || 'DELETE';
  302. body = body || '';
  303. querystring = snakeCaseKeys(null, snakeCase, querystring);
  304. return this.transport.request({ method, path, body, querystring }, options, callback);
  305. };
  306. /**
  307. * Delete the specified role.
  308. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#delete-role - Security - Delete Role}
  309. *
  310. * @memberOf API-Security
  311. *
  312. * @param {Object} params
  313. * @param {string} params.role
  314. *
  315. * @param {Object} options - Options for {@link Transport#request}
  316. * @param {function} callback - Callback that handles errors and response
  317. *
  318. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  319. */
  320. SecurityApi.prototype.deleteRole = function securityDeleteRoleApi(params, options, callback) {
  321. [params, options, callback] = normalizeArguments(params, options, callback);
  322. if (params.role == null) {
  323. const err = new this[kConfigurationError]('Missing required parameter: role');
  324. return handleError(err, callback);
  325. }
  326. let { method, body, role, ...querystring } = params;
  327. role = encodePathParam(role);
  328. let path = ['', '_plugins', '_security', 'api', 'roles', role].filter((c) => c != null).join('/');
  329. method = method || 'DELETE';
  330. body = body || '';
  331. querystring = snakeCaseKeys(null, snakeCase, querystring);
  332. return this.transport.request({ method, path, body, querystring }, options, callback);
  333. };
  334. /**
  335. * Deletes the specified role mapping.
  336. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#delete-role-mapping - Security - Delete Role Mapping}
  337. *
  338. * @memberOf API-Security
  339. *
  340. * @param {Object} params
  341. * @param {string} params.role
  342. *
  343. * @param {Object} options - Options for {@link Transport#request}
  344. * @param {function} callback - Callback that handles errors and response
  345. *
  346. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  347. */
  348. SecurityApi.prototype.deleteRoleMapping = function securityDeleteRoleMappingApi(
  349. params,
  350. options,
  351. callback
  352. ) {
  353. [params, options, callback] = normalizeArguments(params, options, callback);
  354. if (params.role == null) {
  355. const err = new this[kConfigurationError]('Missing required parameter: role');
  356. return handleError(err, callback);
  357. }
  358. let { method, body, role, ...querystring } = params;
  359. role = encodePathParam(role);
  360. let path = ['', '_plugins', '_security', 'api', 'rolesmapping', role]
  361. .filter((c) => c != null)
  362. .join('/');
  363. method = method || 'DELETE';
  364. body = body || '';
  365. querystring = snakeCaseKeys(null, snakeCase, querystring);
  366. return this.transport.request({ method, path, body, querystring }, options, callback);
  367. };
  368. /**
  369. * Delete the specified tenant.
  370. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#delete-action-group - Security - Delete Tenant}
  371. *
  372. * @memberOf API-Security
  373. *
  374. * @param {Object} params
  375. * @param {string} params.tenant
  376. *
  377. * @param {Object} options - Options for {@link Transport#request}
  378. * @param {function} callback - Callback that handles errors and response
  379. *
  380. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  381. */
  382. SecurityApi.prototype.deleteTenant = function securityDeleteTenantApi(params, options, callback) {
  383. [params, options, callback] = normalizeArguments(params, options, callback);
  384. if (params.tenant == null) {
  385. const err = new this[kConfigurationError]('Missing required parameter: tenant');
  386. return handleError(err, callback);
  387. }
  388. let { method, body, tenant, ...querystring } = params;
  389. tenant = encodePathParam(tenant);
  390. let path = ['', '_plugins', '_security', 'api', 'tenants', tenant]
  391. .filter((c) => c != null)
  392. .join('/');
  393. method = method || 'DELETE';
  394. body = body || '';
  395. querystring = snakeCaseKeys(null, snakeCase, querystring);
  396. return this.transport.request({ method, path, body, querystring }, options, callback);
  397. };
  398. /**
  399. * Delete the specified user.
  400. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#delete-user - Security - Delete User}
  401. *
  402. * @memberOf API-Security
  403. *
  404. * @param {Object} params
  405. * @param {string} params.username
  406. *
  407. * @param {Object} options - Options for {@link Transport#request}
  408. * @param {function} callback - Callback that handles errors and response
  409. *
  410. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  411. */
  412. SecurityApi.prototype.deleteUser = function securityDeleteUserApi(params, options, callback) {
  413. [params, options, callback] = normalizeArguments(params, options, callback);
  414. if (params.username == null) {
  415. const err = new this[kConfigurationError]('Missing required parameter: username');
  416. return handleError(err, callback);
  417. }
  418. let { method, body, username, ...querystring } = params;
  419. username = encodePathParam(username);
  420. let path = ['', '_plugins', '_security', 'api', 'internalusers', username]
  421. .filter((c) => c != null)
  422. .join('/');
  423. method = method || 'DELETE';
  424. body = body || '';
  425. querystring = snakeCaseKeys(null, snakeCase, querystring);
  426. return this.transport.request({ method, path, body, querystring }, options, callback);
  427. };
  428. /**
  429. * Flushes the Security plugin user, authentication, and authorization cache.
  430. * <br/> See Also: {@link https://opensearch.org/docs/2.7/security/access-control/api/#flush-cache - Security - Flush Cache}
  431. *
  432. * @memberOf API-Security
  433. *
  434. * @param {Object} params
  435. *
  436. * @param {Object} options - Options for {@link Transport#request}
  437. * @param {function} callback - Callback that handles errors and response
  438. *
  439. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  440. */
  441. SecurityApi.prototype.flushCache = function securityFlushCacheApi(params, options, callback) {
  442. [params, options, callback] = normalizeArguments(params, options, callback);
  443. let { method, body, ...querystring } = params;
  444. let path = ['', '_plugins', '_security', 'api', 'cache'].filter((c) => c != null).join('/');
  445. method = method || 'DELETE';
  446. body = body || '';
  447. querystring = snakeCaseKeys(null, snakeCase, querystring);
  448. return this.transport.request({ method, path, body, querystring }, options, callback);
  449. };
  450. /**
  451. * Returns account details for the current user.
  452. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#get-account-details - Security - Get Account Details}
  453. *
  454. * @memberOf API-Security
  455. *
  456. * @param {Object} params
  457. *
  458. * @param {Object} options - Options for {@link Transport#request}
  459. * @param {function} callback - Callback that handles errors and response
  460. *
  461. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  462. */
  463. SecurityApi.prototype.getAccountDetails = function securityGetAccountDetailsApi(
  464. params,
  465. options,
  466. callback
  467. ) {
  468. [params, options, callback] = normalizeArguments(params, options, callback);
  469. let { method, body, ...querystring } = params;
  470. let path = ['', '_plugins', '_security', 'api', 'account'].filter((c) => c != null).join('/');
  471. method = method || 'GET';
  472. body = body || '';
  473. querystring = snakeCaseKeys(null, snakeCase, querystring);
  474. return this.transport.request({ method, path, body, querystring }, options, callback);
  475. };
  476. /**
  477. * Retrieves one action group.
  478. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#get-action-group - Security - Get Action Group}
  479. *
  480. * @memberOf API-Security
  481. *
  482. * @param {Object} params
  483. * @param {string} params.action_group - Action group to retrieve.
  484. *
  485. * @param {Object} options - Options for {@link Transport#request}
  486. * @param {function} callback - Callback that handles errors and response
  487. *
  488. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  489. */
  490. SecurityApi.prototype.getActionGroup = function securityGetActionGroupApi(
  491. params,
  492. options,
  493. callback
  494. ) {
  495. [params, options, callback] = normalizeArguments(params, options, callback);
  496. if (params.actionGroup == null && params.action_group == null) {
  497. const err = new this[kConfigurationError]('Missing required parameter: action_group');
  498. return handleError(err, callback);
  499. }
  500. let { method, body, actionGroup, action_group, ...querystring } = params;
  501. action_group = encodePathParam(actionGroup, action_group);
  502. let path = ['', '_plugins', '_security', 'api', 'actiongroups', action_group]
  503. .filter((c) => c != null)
  504. .join('/');
  505. method = method || 'GET';
  506. body = body || '';
  507. querystring = snakeCaseKeys(null, snakeCase, querystring);
  508. return this.transport.request({ method, path, body, querystring }, options, callback);
  509. };
  510. /**
  511. * Retrieves all action groups.
  512. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#get-action-groups - Security - Get Action Groups}
  513. *
  514. * @memberOf API-Security
  515. *
  516. * @param {Object} params
  517. *
  518. * @param {Object} options - Options for {@link Transport#request}
  519. * @param {function} callback - Callback that handles errors and response
  520. *
  521. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  522. */
  523. SecurityApi.prototype.getActionGroups = function securityGetActionGroupsApi(
  524. params,
  525. options,
  526. callback
  527. ) {
  528. [params, options, callback] = normalizeArguments(params, options, callback);
  529. let { method, body, ...querystring } = params;
  530. let path = ['', '_plugins', '_security', 'api', 'actiongroups']
  531. .filter((c) => c != null)
  532. .join('/');
  533. method = method || 'GET';
  534. body = body || '';
  535. querystring = snakeCaseKeys(null, snakeCase, querystring);
  536. return this.transport.request({ method, path, body, querystring }, options, callback);
  537. };
  538. /**
  539. * Retrieves the audit configuration.
  540. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#audit-logs - Security - Get Audit Configuration}
  541. *
  542. * @memberOf API-Security
  543. *
  544. * @param {Object} params
  545. *
  546. * @param {Object} options - Options for {@link Transport#request}
  547. * @param {function} callback - Callback that handles errors and response
  548. *
  549. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  550. */
  551. SecurityApi.prototype.getAuditConfiguration = function securityGetAuditConfigurationApi(
  552. params,
  553. options,
  554. callback
  555. ) {
  556. [params, options, callback] = normalizeArguments(params, options, callback);
  557. let { method, body, ...querystring } = params;
  558. let path = ['', '_plugins', '_security', 'api', 'audit'].filter((c) => c != null).join('/');
  559. method = method || 'GET';
  560. body = body || '';
  561. querystring = snakeCaseKeys(null, snakeCase, querystring);
  562. return this.transport.request({ method, path, body, querystring }, options, callback);
  563. };
  564. /**
  565. * Retrieves the cluster’s security certificates.
  566. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#get-certificates - Security - Get Certificates}
  567. *
  568. * @memberOf API-Security
  569. *
  570. * @param {Object} params
  571. *
  572. * @param {Object} options - Options for {@link Transport#request}
  573. * @param {function} callback - Callback that handles errors and response
  574. *
  575. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  576. */
  577. SecurityApi.prototype.getCertificates = function securityGetCertificatesApi(
  578. params,
  579. options,
  580. callback
  581. ) {
  582. [params, options, callback] = normalizeArguments(params, options, callback);
  583. let { method, body, ...querystring } = params;
  584. let path = ['', '_plugins', '_security', 'api', 'ssl', 'certs']
  585. .filter((c) => c != null)
  586. .join('/');
  587. method = method || 'GET';
  588. body = body || '';
  589. querystring = snakeCaseKeys(null, snakeCase, querystring);
  590. return this.transport.request({ method, path, body, querystring }, options, callback);
  591. };
  592. /**
  593. * Returns the current Security plugin configuration in JSON format.
  594. * <br/> See Also: {@link https://opensearch.org/docs/2.7/security/access-control/api/#get-configuration - Security - Get Configuration}
  595. *
  596. * @memberOf API-Security
  597. *
  598. * @param {Object} params
  599. *
  600. * @param {Object} options - Options for {@link Transport#request}
  601. * @param {function} callback - Callback that handles errors and response
  602. *
  603. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  604. */
  605. SecurityApi.prototype.getConfiguration = function securityGetConfigurationApi(
  606. params,
  607. options,
  608. callback
  609. ) {
  610. [params, options, callback] = normalizeArguments(params, options, callback);
  611. let { method, body, ...querystring } = params;
  612. let path = ['', '_plugins', '_security', 'api', 'securityconfig']
  613. .filter((c) => c != null)
  614. .join('/');
  615. method = method || 'GET';
  616. body = body || '';
  617. querystring = snakeCaseKeys(null, snakeCase, querystring);
  618. return this.transport.request({ method, path, body, querystring }, options, callback);
  619. };
  620. /**
  621. * Retrieves all distinguished names in the allow list.
  622. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#get-distinguished-names - Security - Get Distinguished Names}
  623. *
  624. * @memberOf API-Security
  625. *
  626. * @param {Object} params
  627. * @param {string} [params.cluster_name]
  628. *
  629. * @param {Object} options - Options for {@link Transport#request}
  630. * @param {function} callback - Callback that handles errors and response
  631. *
  632. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  633. */
  634. SecurityApi.prototype.getDistinguishedNames = function securityGetDistinguishedNamesApi(
  635. params,
  636. options,
  637. callback
  638. ) {
  639. [params, options, callback] = normalizeArguments(params, options, callback);
  640. let { method, body, clusterName, cluster_name, ...querystring } = params;
  641. cluster_name = encodePathParam(clusterName, cluster_name);
  642. let path = ['', '_plugins', '_security', 'api', 'nodesdn', cluster_name]
  643. .filter((c) => c != null)
  644. .join('/');
  645. method = method || 'GET';
  646. body = body || '';
  647. querystring = snakeCaseKeys(null, snakeCase, querystring);
  648. return this.transport.request({ method, path, body, querystring }, options, callback);
  649. };
  650. /**
  651. * Retrieves one role.
  652. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#get-role - Security - Get Role}
  653. *
  654. * @memberOf API-Security
  655. *
  656. * @param {Object} params
  657. * @param {string} params.role
  658. *
  659. * @param {Object} options - Options for {@link Transport#request}
  660. * @param {function} callback - Callback that handles errors and response
  661. *
  662. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  663. */
  664. SecurityApi.prototype.getRole = function securityGetRoleApi(params, options, callback) {
  665. [params, options, callback] = normalizeArguments(params, options, callback);
  666. if (params.role == null) {
  667. const err = new this[kConfigurationError]('Missing required parameter: role');
  668. return handleError(err, callback);
  669. }
  670. let { method, body, role, ...querystring } = params;
  671. role = encodePathParam(role);
  672. let path = ['', '_plugins', '_security', 'api', 'roles', role].filter((c) => c != null).join('/');
  673. method = method || 'GET';
  674. body = body || '';
  675. querystring = snakeCaseKeys(null, snakeCase, querystring);
  676. return this.transport.request({ method, path, body, querystring }, options, callback);
  677. };
  678. /**
  679. * Retrieves one role mapping.
  680. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#get-role-mapping - Security - Get Role Mapping}
  681. *
  682. * @memberOf API-Security
  683. *
  684. * @param {Object} params
  685. * @param {string} params.role
  686. *
  687. * @param {Object} options - Options for {@link Transport#request}
  688. * @param {function} callback - Callback that handles errors and response
  689. *
  690. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  691. */
  692. SecurityApi.prototype.getRoleMapping = function securityGetRoleMappingApi(
  693. params,
  694. options,
  695. callback
  696. ) {
  697. [params, options, callback] = normalizeArguments(params, options, callback);
  698. if (params.role == null) {
  699. const err = new this[kConfigurationError]('Missing required parameter: role');
  700. return handleError(err, callback);
  701. }
  702. let { method, body, role, ...querystring } = params;
  703. role = encodePathParam(role);
  704. let path = ['', '_plugins', '_security', 'api', 'rolesmapping', role]
  705. .filter((c) => c != null)
  706. .join('/');
  707. method = method || 'GET';
  708. body = body || '';
  709. querystring = snakeCaseKeys(null, snakeCase, querystring);
  710. return this.transport.request({ method, path, body, querystring }, options, callback);
  711. };
  712. /**
  713. * Retrieves all role mappings.
  714. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#get-role-mappings - Security - Get Role Mappings}
  715. *
  716. * @memberOf API-Security
  717. *
  718. * @param {Object} params
  719. *
  720. * @param {Object} options - Options for {@link Transport#request}
  721. * @param {function} callback - Callback that handles errors and response
  722. *
  723. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  724. */
  725. SecurityApi.prototype.getRoleMappings = function securityGetRoleMappingsApi(
  726. params,
  727. options,
  728. callback
  729. ) {
  730. [params, options, callback] = normalizeArguments(params, options, callback);
  731. let { method, body, ...querystring } = params;
  732. let path = ['', '_plugins', '_security', 'api', 'rolesmapping']
  733. .filter((c) => c != null)
  734. .join('/');
  735. method = method || 'GET';
  736. body = body || '';
  737. querystring = snakeCaseKeys(null, snakeCase, querystring);
  738. return this.transport.request({ method, path, body, querystring }, options, callback);
  739. };
  740. /**
  741. * Retrieves all roles.
  742. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#get-roles - Security - Get Roles}
  743. *
  744. * @memberOf API-Security
  745. *
  746. * @param {Object} params
  747. *
  748. * @param {Object} options - Options for {@link Transport#request}
  749. * @param {function} callback - Callback that handles errors and response
  750. *
  751. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  752. */
  753. SecurityApi.prototype.getRoles = function securityGetRolesApi(params, options, callback) {
  754. [params, options, callback] = normalizeArguments(params, options, callback);
  755. let { method, body, ...querystring } = params;
  756. let path = ['', '_plugins', '_security', 'api', 'roles'].filter((c) => c != null).join('/');
  757. method = method || 'GET';
  758. body = body || '';
  759. querystring = snakeCaseKeys(null, snakeCase, querystring);
  760. return this.transport.request({ method, path, body, querystring }, options, callback);
  761. };
  762. /**
  763. * Retrieves one tenant.
  764. * <br/> See Also: {@link https://opensearch.org/docs/2.7/security/access-control/api/#get-tenant - Security - Get Tenant}
  765. *
  766. * @memberOf API-Security
  767. *
  768. * @param {Object} params
  769. * @param {string} params.tenant
  770. *
  771. * @param {Object} options - Options for {@link Transport#request}
  772. * @param {function} callback - Callback that handles errors and response
  773. *
  774. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  775. */
  776. SecurityApi.prototype.getTenant = function securityGetTenantApi(params, options, callback) {
  777. [params, options, callback] = normalizeArguments(params, options, callback);
  778. if (params.tenant == null) {
  779. const err = new this[kConfigurationError]('Missing required parameter: tenant');
  780. return handleError(err, callback);
  781. }
  782. let { method, body, tenant, ...querystring } = params;
  783. tenant = encodePathParam(tenant);
  784. let path = ['', '_plugins', '_security', 'api', 'tenants', tenant]
  785. .filter((c) => c != null)
  786. .join('/');
  787. method = method || 'GET';
  788. body = body || '';
  789. querystring = snakeCaseKeys(null, snakeCase, querystring);
  790. return this.transport.request({ method, path, body, querystring }, options, callback);
  791. };
  792. /**
  793. * Retrieves all tenants.
  794. * <br/> See Also: {@link https://opensearch.org/docs/2.7/security/access-control/api/#get-tenants - Security - Get Tenants}
  795. *
  796. * @memberOf API-Security
  797. *
  798. * @param {Object} params
  799. *
  800. * @param {Object} options - Options for {@link Transport#request}
  801. * @param {function} callback - Callback that handles errors and response
  802. *
  803. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  804. */
  805. SecurityApi.prototype.getTenants = function securityGetTenantsApi(params, options, callback) {
  806. [params, options, callback] = normalizeArguments(params, options, callback);
  807. let { method, body, ...querystring } = params;
  808. let path = ['', '_plugins', '_security', 'api', 'tenants'].filter((c) => c != null).join('/');
  809. method = method || 'GET';
  810. body = body || '';
  811. querystring = snakeCaseKeys(null, snakeCase, querystring);
  812. return this.transport.request({ method, path, body, querystring }, options, callback);
  813. };
  814. /**
  815. * Retrieve one internal user.
  816. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#get-user - Security - Get User}
  817. *
  818. * @memberOf API-Security
  819. *
  820. * @param {Object} params
  821. * @param {string} params.username
  822. *
  823. * @param {Object} options - Options for {@link Transport#request}
  824. * @param {function} callback - Callback that handles errors and response
  825. *
  826. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  827. */
  828. SecurityApi.prototype.getUser = function securityGetUserApi(params, options, callback) {
  829. [params, options, callback] = normalizeArguments(params, options, callback);
  830. if (params.username == null) {
  831. const err = new this[kConfigurationError]('Missing required parameter: username');
  832. return handleError(err, callback);
  833. }
  834. let { method, body, username, ...querystring } = params;
  835. username = encodePathParam(username);
  836. let path = ['', '_plugins', '_security', 'api', 'internalusers', username]
  837. .filter((c) => c != null)
  838. .join('/');
  839. method = method || 'GET';
  840. body = body || '';
  841. querystring = snakeCaseKeys(null, snakeCase, querystring);
  842. return this.transport.request({ method, path, body, querystring }, options, callback);
  843. };
  844. /**
  845. * Retrieve all internal users.
  846. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#get-users - Security - Get Users}
  847. *
  848. * @memberOf API-Security
  849. *
  850. * @param {Object} params
  851. *
  852. * @param {Object} options - Options for {@link Transport#request}
  853. * @param {function} callback - Callback that handles errors and response
  854. *
  855. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  856. */
  857. SecurityApi.prototype.getUsers = function securityGetUsersApi(params, options, callback) {
  858. [params, options, callback] = normalizeArguments(params, options, callback);
  859. let { method, body, ...querystring } = params;
  860. let path = ['', '_plugins', '_security', 'api', 'internalusers']
  861. .filter((c) => c != null)
  862. .join('/');
  863. method = method || 'GET';
  864. body = body || '';
  865. querystring = snakeCaseKeys(null, snakeCase, querystring);
  866. return this.transport.request({ method, path, body, querystring }, options, callback);
  867. };
  868. /**
  869. * Checks to see if the Security plugin is up and running.
  870. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#health-check - Security - Health}
  871. *
  872. * @memberOf API-Security
  873. *
  874. * @param {Object} params
  875. *
  876. * @param {Object} options - Options for {@link Transport#request}
  877. * @param {function} callback - Callback that handles errors and response
  878. *
  879. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  880. */
  881. SecurityApi.prototype.health = function securityHealthApi(params, options, callback) {
  882. [params, options, callback] = normalizeArguments(params, options, callback);
  883. let { method, body, ...querystring } = params;
  884. let path = ['', '_plugins', '_security', 'health'].filter((c) => c != null).join('/');
  885. method = method || 'GET';
  886. body = body || '';
  887. querystring = snakeCaseKeys(null, snakeCase, querystring);
  888. return this.transport.request({ method, path, body, querystring }, options, callback);
  889. };
  890. /**
  891. * Updates individual attributes of an action group.
  892. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#patch-action-group - Security - Patch Action Group}
  893. *
  894. * @memberOf API-Security
  895. *
  896. * @param {Object} params
  897. * @param {string} params.action_group
  898. * @param {Object} params.body
  899. *
  900. * @param {Object} options - Options for {@link Transport#request}
  901. * @param {function} callback - Callback that handles errors and response
  902. *
  903. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  904. */
  905. SecurityApi.prototype.patchActionGroup = function securityPatchActionGroupApi(
  906. params,
  907. options,
  908. callback
  909. ) {
  910. [params, options, callback] = normalizeArguments(params, options, callback);
  911. if (params.actionGroup == null && params.action_group == null) {
  912. const err = new this[kConfigurationError]('Missing required parameter: action_group');
  913. return handleError(err, callback);
  914. }
  915. if (params.body == null) {
  916. const err = new this[kConfigurationError]('Missing required parameter: body');
  917. return handleError(err, callback);
  918. }
  919. let { method, body, actionGroup, action_group, ...querystring } = params;
  920. action_group = encodePathParam(actionGroup, action_group);
  921. let path = ['', '_plugins', '_security', 'api', 'actiongroups', action_group]
  922. .filter((c) => c != null)
  923. .join('/');
  924. method = method || 'PATCH';
  925. body = body || '';
  926. querystring = snakeCaseKeys(null, snakeCase, querystring);
  927. return this.transport.request({ method, path, body, querystring }, options, callback);
  928. };
  929. /**
  930. * Creates, updates, or deletes multiple action groups in a single call.
  931. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#patch-action-groups - Security - Patch Action Groups}
  932. *
  933. * @memberOf API-Security
  934. *
  935. * @param {Object} params
  936. * @param {Object} params.body
  937. *
  938. * @param {Object} options - Options for {@link Transport#request}
  939. * @param {function} callback - Callback that handles errors and response
  940. *
  941. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  942. */
  943. SecurityApi.prototype.patchActionGroups = function securityPatchActionGroupsApi(
  944. params,
  945. options,
  946. callback
  947. ) {
  948. [params, options, callback] = normalizeArguments(params, options, callback);
  949. if (params.body == null) {
  950. const err = new this[kConfigurationError]('Missing required parameter: body');
  951. return handleError(err, callback);
  952. }
  953. let { method, body, ...querystring } = params;
  954. let path = ['', '_plugins', '_security', 'api', 'actiongroups']
  955. .filter((c) => c != null)
  956. .join('/');
  957. method = method || 'PATCH';
  958. body = body || '';
  959. querystring = snakeCaseKeys(null, snakeCase, querystring);
  960. return this.transport.request({ method, path, body, querystring }, options, callback);
  961. };
  962. /**
  963. * A PATCH call is used to update specified fields in the audit configuration.
  964. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#audit-logs - Security - Patch Audit Configuration}
  965. *
  966. * @memberOf API-Security
  967. *
  968. * @param {Object} params
  969. * @param {Object} params.body
  970. *
  971. * @param {Object} options - Options for {@link Transport#request}
  972. * @param {function} callback - Callback that handles errors and response
  973. *
  974. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  975. */
  976. SecurityApi.prototype.patchAuditConfiguration = function securityPatchAuditConfigurationApi(
  977. params,
  978. options,
  979. callback
  980. ) {
  981. [params, options, callback] = normalizeArguments(params, options, callback);
  982. if (params.body == null) {
  983. const err = new this[kConfigurationError]('Missing required parameter: body');
  984. return handleError(err, callback);
  985. }
  986. let { method, body, ...querystring } = params;
  987. let path = ['', '_plugins', '_security', 'api', 'audit'].filter((c) => c != null).join('/');
  988. method = method || 'PATCH';
  989. body = body || '';
  990. querystring = snakeCaseKeys(null, snakeCase, querystring);
  991. return this.transport.request({ method, path, body, querystring }, options, callback);
  992. };
  993. /**
  994. * A PATCH call is used to update the existing configuration using the REST API.
  995. * <br/> See Also: {@link https://opensearch.org/docs/2.7/security/access-control/api/#patch-configuration - Security - Patch Configuration}
  996. *
  997. * @memberOf API-Security
  998. *
  999. * @param {Object} params
  1000. * @param {Object} params.body
  1001. *
  1002. * @param {Object} options - Options for {@link Transport#request}
  1003. * @param {function} callback - Callback that handles errors and response
  1004. *
  1005. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1006. */
  1007. SecurityApi.prototype.patchConfiguration = function securityPatchConfigurationApi(
  1008. params,
  1009. options,
  1010. callback
  1011. ) {
  1012. [params, options, callback] = normalizeArguments(params, options, callback);
  1013. if (params.body == null) {
  1014. const err = new this[kConfigurationError]('Missing required parameter: body');
  1015. return handleError(err, callback);
  1016. }
  1017. let { method, body, ...querystring } = params;
  1018. let path = ['', '_plugins', '_security', 'api', 'securityconfig']
  1019. .filter((c) => c != null)
  1020. .join('/');
  1021. method = method || 'PATCH';
  1022. body = body || '';
  1023. querystring = snakeCaseKeys(null, snakeCase, querystring);
  1024. return this.transport.request({ method, path, body, querystring }, options, callback);
  1025. };
  1026. /**
  1027. * Bulk update of distinguished names.
  1028. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#update-all-distinguished-names - Security - Patch Distinguished Names}
  1029. *
  1030. * @memberOf API-Security
  1031. *
  1032. * @param {Object} params
  1033. * @param {Object} params.body
  1034. *
  1035. * @param {Object} options - Options for {@link Transport#request}
  1036. * @param {function} callback - Callback that handles errors and response
  1037. *
  1038. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1039. */
  1040. SecurityApi.prototype.patchDistinguishedNames = function securityPatchDistinguishedNamesApi(
  1041. params,
  1042. options,
  1043. callback
  1044. ) {
  1045. [params, options, callback] = normalizeArguments(params, options, callback);
  1046. if (params.body == null) {
  1047. const err = new this[kConfigurationError]('Missing required parameter: body');
  1048. return handleError(err, callback);
  1049. }
  1050. let { method, body, ...querystring } = params;
  1051. let path = ['', '_plugins', '_security', 'api', 'nodesdn'].filter((c) => c != null).join('/');
  1052. method = method || 'PATCH';
  1053. body = body || '';
  1054. querystring = snakeCaseKeys(null, snakeCase, querystring);
  1055. return this.transport.request({ method, path, body, querystring }, options, callback);
  1056. };
  1057. /**
  1058. * Updates individual attributes of a role.
  1059. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#patch-role - Security - Patch Role}
  1060. *
  1061. * @memberOf API-Security
  1062. *
  1063. * @param {Object} params
  1064. * @param {string} params.role
  1065. * @param {Object} params.body
  1066. *
  1067. * @param {Object} options - Options for {@link Transport#request}
  1068. * @param {function} callback - Callback that handles errors and response
  1069. *
  1070. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1071. */
  1072. SecurityApi.prototype.patchRole = function securityPatchRoleApi(params, options, callback) {
  1073. [params, options, callback] = normalizeArguments(params, options, callback);
  1074. if (params.role == null) {
  1075. const err = new this[kConfigurationError]('Missing required parameter: role');
  1076. return handleError(err, callback);
  1077. }
  1078. if (params.body == null) {
  1079. const err = new this[kConfigurationError]('Missing required parameter: body');
  1080. return handleError(err, callback);
  1081. }
  1082. let { method, body, role, ...querystring } = params;
  1083. role = encodePathParam(role);
  1084. let path = ['', '_plugins', '_security', 'api', 'roles', role].filter((c) => c != null).join('/');
  1085. method = method || 'PATCH';
  1086. body = body || '';
  1087. querystring = snakeCaseKeys(null, snakeCase, querystring);
  1088. return this.transport.request({ method, path, body, querystring }, options, callback);
  1089. };
  1090. /**
  1091. * Updates individual attributes of a role mapping.
  1092. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#patch-role-mapping - Security - Patch Role Mapping}
  1093. *
  1094. * @memberOf API-Security
  1095. *
  1096. * @param {Object} params
  1097. * @param {string} params.role
  1098. * @param {Object} params.body
  1099. *
  1100. * @param {Object} options - Options for {@link Transport#request}
  1101. * @param {function} callback - Callback that handles errors and response
  1102. *
  1103. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1104. */
  1105. SecurityApi.prototype.patchRoleMapping = function securityPatchRoleMappingApi(
  1106. params,
  1107. options,
  1108. callback
  1109. ) {
  1110. [params, options, callback] = normalizeArguments(params, options, callback);
  1111. if (params.role == null) {
  1112. const err = new this[kConfigurationError]('Missing required parameter: role');
  1113. return handleError(err, callback);
  1114. }
  1115. if (params.body == null) {
  1116. const err = new this[kConfigurationError]('Missing required parameter: body');
  1117. return handleError(err, callback);
  1118. }
  1119. let { method, body, role, ...querystring } = params;
  1120. role = encodePathParam(role);
  1121. let path = ['', '_plugins', '_security', 'api', 'rolesmapping', role]
  1122. .filter((c) => c != null)
  1123. .join('/');
  1124. method = method || 'PATCH';
  1125. body = body || '';
  1126. querystring = snakeCaseKeys(null, snakeCase, querystring);
  1127. return this.transport.request({ method, path, body, querystring }, options, callback);
  1128. };
  1129. /**
  1130. * Creates or updates multiple role mappings in a single call.
  1131. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#patch-role-mappings - Security - Patch Role Mappings}
  1132. *
  1133. * @memberOf API-Security
  1134. *
  1135. * @param {Object} params
  1136. * @param {Object} params.body
  1137. *
  1138. * @param {Object} options - Options for {@link Transport#request}
  1139. * @param {function} callback - Callback that handles errors and response
  1140. *
  1141. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1142. */
  1143. SecurityApi.prototype.patchRoleMappings = function securityPatchRoleMappingsApi(
  1144. params,
  1145. options,
  1146. callback
  1147. ) {
  1148. [params, options, callback] = normalizeArguments(params, options, callback);
  1149. if (params.body == null) {
  1150. const err = new this[kConfigurationError]('Missing required parameter: body');
  1151. return handleError(err, callback);
  1152. }
  1153. let { method, body, ...querystring } = params;
  1154. let path = ['', '_plugins', '_security', 'api', 'rolesmapping']
  1155. .filter((c) => c != null)
  1156. .join('/');
  1157. method = method || 'PATCH';
  1158. body = body || '';
  1159. querystring = snakeCaseKeys(null, snakeCase, querystring);
  1160. return this.transport.request({ method, path, body, querystring }, options, callback);
  1161. };
  1162. /**
  1163. * Creates, updates, or deletes multiple roles in a single call.
  1164. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#patch-roles - Security - Patch Roles}
  1165. *
  1166. * @memberOf API-Security
  1167. *
  1168. * @param {Object} params
  1169. * @param {Object} params.body
  1170. *
  1171. * @param {Object} options - Options for {@link Transport#request}
  1172. * @param {function} callback - Callback that handles errors and response
  1173. *
  1174. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1175. */
  1176. SecurityApi.prototype.patchRoles = function securityPatchRolesApi(params, options, callback) {
  1177. [params, options, callback] = normalizeArguments(params, options, callback);
  1178. if (params.body == null) {
  1179. const err = new this[kConfigurationError]('Missing required parameter: body');
  1180. return handleError(err, callback);
  1181. }
  1182. let { method, body, ...querystring } = params;
  1183. let path = ['', '_plugins', '_security', 'api', 'roles'].filter((c) => c != null).join('/');
  1184. method = method || 'PATCH';
  1185. body = body || '';
  1186. querystring = snakeCaseKeys(null, snakeCase, querystring);
  1187. return this.transport.request({ method, path, body, querystring }, options, callback);
  1188. };
  1189. /**
  1190. * Add, delete, or modify a single tenant.
  1191. * <br/> See Also: {@link https://opensearch.org/docs/2.7/security/access-control/api/#patch-tenant - Security - Patch Tenant}
  1192. *
  1193. * @memberOf API-Security
  1194. *
  1195. * @param {Object} params
  1196. * @param {string} params.tenant
  1197. * @param {Object} params.body
  1198. *
  1199. * @param {Object} options - Options for {@link Transport#request}
  1200. * @param {function} callback - Callback that handles errors and response
  1201. *
  1202. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1203. */
  1204. SecurityApi.prototype.patchTenant = function securityPatchTenantApi(params, options, callback) {
  1205. [params, options, callback] = normalizeArguments(params, options, callback);
  1206. if (params.tenant == null) {
  1207. const err = new this[kConfigurationError]('Missing required parameter: tenant');
  1208. return handleError(err, callback);
  1209. }
  1210. if (params.body == null) {
  1211. const err = new this[kConfigurationError]('Missing required parameter: body');
  1212. return handleError(err, callback);
  1213. }
  1214. let { method, body, tenant, ...querystring } = params;
  1215. tenant = encodePathParam(tenant);
  1216. let path = ['', '_plugins', '_security', 'api', 'tenants', tenant]
  1217. .filter((c) => c != null)
  1218. .join('/');
  1219. method = method || 'PATCH';
  1220. body = body || '';
  1221. querystring = snakeCaseKeys(null, snakeCase, querystring);
  1222. return this.transport.request({ method, path, body, querystring }, options, callback);
  1223. };
  1224. /**
  1225. * Add, delete, or modify multiple tenants in a single call.
  1226. * <br/> See Also: {@link https://opensearch.org/docs/2.7/security/access-control/api/#patch-tenants - Security - Patch Tenants}
  1227. *
  1228. * @memberOf API-Security
  1229. *
  1230. * @param {Object} params
  1231. * @param {Object} params.body
  1232. *
  1233. * @param {Object} options - Options for {@link Transport#request}
  1234. * @param {function} callback - Callback that handles errors and response
  1235. *
  1236. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1237. */
  1238. SecurityApi.prototype.patchTenants = function securityPatchTenantsApi(params, options, callback) {
  1239. [params, options, callback] = normalizeArguments(params, options, callback);
  1240. if (params.body == null) {
  1241. const err = new this[kConfigurationError]('Missing required parameter: body');
  1242. return handleError(err, callback);
  1243. }
  1244. let { method, body, ...querystring } = params;
  1245. let path = ['', '_plugins', '_security', 'api', 'tenants'].filter((c) => c != null).join('/');
  1246. method = method || 'PATCH';
  1247. body = body || '';
  1248. querystring = snakeCaseKeys(null, snakeCase, querystring);
  1249. return this.transport.request({ method, path, body, querystring }, options, callback);
  1250. };
  1251. /**
  1252. * Updates individual attributes of an internal user.
  1253. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#patch-user - Security - Patch User}
  1254. *
  1255. * @memberOf API-Security
  1256. *
  1257. * @param {Object} params
  1258. * @param {string} params.username
  1259. * @param {Object} params.body
  1260. *
  1261. * @param {Object} options - Options for {@link Transport#request}
  1262. * @param {function} callback - Callback that handles errors and response
  1263. *
  1264. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1265. */
  1266. SecurityApi.prototype.patchUser = function securityPatchUserApi(params, options, callback) {
  1267. [params, options, callback] = normalizeArguments(params, options, callback);
  1268. if (params.username == null) {
  1269. const err = new this[kConfigurationError]('Missing required parameter: username');
  1270. return handleError(err, callback);
  1271. }
  1272. if (params.body == null) {
  1273. const err = new this[kConfigurationError]('Missing required parameter: body');
  1274. return handleError(err, callback);
  1275. }
  1276. let { method, body, username, ...querystring } = params;
  1277. username = encodePathParam(username);
  1278. let path = ['', '_plugins', '_security', 'api', 'internalusers', username]
  1279. .filter((c) => c != null)
  1280. .join('/');
  1281. method = method || 'PATCH';
  1282. body = body || '';
  1283. querystring = snakeCaseKeys(null, snakeCase, querystring);
  1284. return this.transport.request({ method, path, body, querystring }, options, callback);
  1285. };
  1286. /**
  1287. * Creates, updates, or deletes multiple internal users in a single call.
  1288. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#patch-users - Security - Patch Users}
  1289. *
  1290. * @memberOf API-Security
  1291. *
  1292. * @param {Object} params
  1293. * @param {Object} params.body
  1294. *
  1295. * @param {Object} options - Options for {@link Transport#request}
  1296. * @param {function} callback - Callback that handles errors and response
  1297. *
  1298. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1299. */
  1300. SecurityApi.prototype.patchUsers = function securityPatchUsersApi(params, options, callback) {
  1301. [params, options, callback] = normalizeArguments(params, options, callback);
  1302. if (params.body == null) {
  1303. const err = new this[kConfigurationError]('Missing required parameter: body');
  1304. return handleError(err, callback);
  1305. }
  1306. let { method, body, ...querystring } = params;
  1307. let path = ['', '_plugins', '_security', 'api', 'internalusers']
  1308. .filter((c) => c != null)
  1309. .join('/');
  1310. method = method || 'PATCH';
  1311. body = body || '';
  1312. querystring = snakeCaseKeys(null, snakeCase, querystring);
  1313. return this.transport.request({ method, path, body, querystring }, options, callback);
  1314. };
  1315. /**
  1316. * Reload HTTP layer communication certificates.
  1317. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#reload-http-certificates - Security - Reload Http Certificates}
  1318. *
  1319. * @memberOf API-Security
  1320. *
  1321. * @param {Object} params
  1322. *
  1323. * @param {Object} options - Options for {@link Transport#request}
  1324. * @param {function} callback - Callback that handles errors and response
  1325. *
  1326. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1327. */
  1328. SecurityApi.prototype.reloadHttpCertificates = function securityReloadHttpCertificatesApi(
  1329. params,
  1330. options,
  1331. callback
  1332. ) {
  1333. [params, options, callback] = normalizeArguments(params, options, callback);
  1334. let { method, body, ...querystring } = params;
  1335. let path = ['', '_plugins', '_security', 'api', 'ssl', 'http', 'reloadcerts']
  1336. .filter((c) => c != null)
  1337. .join('/');
  1338. method = method || 'PUT';
  1339. body = body || '';
  1340. querystring = snakeCaseKeys(null, snakeCase, querystring);
  1341. return this.transport.request({ method, path, body, querystring }, options, callback);
  1342. };
  1343. /**
  1344. * Reload transport layer communication certificates.
  1345. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#reload-transport-certificates - Security - Reload Transport Certificates}
  1346. *
  1347. * @memberOf API-Security
  1348. *
  1349. * @param {Object} params
  1350. *
  1351. * @param {Object} options - Options for {@link Transport#request}
  1352. * @param {function} callback - Callback that handles errors and response
  1353. *
  1354. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1355. */
  1356. SecurityApi.prototype.reloadTransportCertificates = function securityReloadTransportCertificatesApi(
  1357. params,
  1358. options,
  1359. callback
  1360. ) {
  1361. [params, options, callback] = normalizeArguments(params, options, callback);
  1362. let { method, body, ...querystring } = params;
  1363. let path = ['', '_plugins', '_security', 'api', 'ssl', 'transport', 'reloadcerts']
  1364. .filter((c) => c != null)
  1365. .join('/');
  1366. method = method || 'PUT';
  1367. body = body || '';
  1368. querystring = snakeCaseKeys(null, snakeCase, querystring);
  1369. return this.transport.request({ method, path, body, querystring }, options, callback);
  1370. };
  1371. /**
  1372. * Updates the audit configuration.
  1373. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#audit-logs - Security - Update Audit Configuration}
  1374. *
  1375. * @memberOf API-Security
  1376. *
  1377. * @param {Object} params
  1378. * @param {Object} params.body
  1379. *
  1380. * @param {Object} options - Options for {@link Transport#request}
  1381. * @param {function} callback - Callback that handles errors and response
  1382. *
  1383. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1384. */
  1385. SecurityApi.prototype.updateAuditConfiguration = function securityUpdateAuditConfigurationApi(
  1386. params,
  1387. options,
  1388. callback
  1389. ) {
  1390. [params, options, callback] = normalizeArguments(params, options, callback);
  1391. if (params.body == null) {
  1392. const err = new this[kConfigurationError]('Missing required parameter: body');
  1393. return handleError(err, callback);
  1394. }
  1395. let { method, body, ...querystring } = params;
  1396. let path = ['', '_plugins', '_security', 'api', 'audit', 'config']
  1397. .filter((c) => c != null)
  1398. .join('/');
  1399. method = method || 'PUT';
  1400. body = body || '';
  1401. querystring = snakeCaseKeys(null, snakeCase, querystring);
  1402. return this.transport.request({ method, path, body, querystring }, options, callback);
  1403. };
  1404. /**
  1405. * Adds or updates the existing configuration using the REST API.
  1406. * <br/> See Also: {@link https://opensearch.org/docs/2.7/security/access-control/api/#update-configuration - Security - Update Configuration}
  1407. *
  1408. * @memberOf API-Security
  1409. *
  1410. * @param {Object} params
  1411. * @param {Object} params.body
  1412. *
  1413. * @param {Object} options - Options for {@link Transport#request}
  1414. * @param {function} callback - Callback that handles errors and response
  1415. *
  1416. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1417. */
  1418. SecurityApi.prototype.updateConfiguration = function securityUpdateConfigurationApi(
  1419. params,
  1420. options,
  1421. callback
  1422. ) {
  1423. [params, options, callback] = normalizeArguments(params, options, callback);
  1424. if (params.body == null) {
  1425. const err = new this[kConfigurationError]('Missing required parameter: body');
  1426. return handleError(err, callback);
  1427. }
  1428. let { method, body, ...querystring } = params;
  1429. let path = ['', '_plugins', '_security', 'api', 'securityconfig', 'config']
  1430. .filter((c) => c != null)
  1431. .join('/');
  1432. method = method || 'PUT';
  1433. body = body || '';
  1434. querystring = snakeCaseKeys(null, snakeCase, querystring);
  1435. return this.transport.request({ method, path, body, querystring }, options, callback);
  1436. };
  1437. /**
  1438. * Adds or updates the specified distinguished names in the cluster’s or node’s allow list.
  1439. * <br/> See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#update-distinguished-names - Security - Update Distinguished Names}
  1440. *
  1441. * @memberOf API-Security
  1442. *
  1443. * @param {Object} params
  1444. * @param {string} params.cluster_name
  1445. * @param {Object} [params.body]
  1446. *
  1447. * @param {Object} options - Options for {@link Transport#request}
  1448. * @param {function} callback - Callback that handles errors and response
  1449. *
  1450. * @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
  1451. */
  1452. SecurityApi.prototype.updateDistinguishedNames = function securityUpdateDistinguishedNamesApi(
  1453. params,
  1454. options,
  1455. callback
  1456. ) {
  1457. [params, options, callback] = normalizeArguments(params, options, callback);
  1458. if (params.clusterName == null && params.cluster_name == null) {
  1459. const err = new this[kConfigurationError]('Missing required parameter: cluster_name');
  1460. return handleError(err, callback);
  1461. }
  1462. let { method, body, clusterName, cluster_name, ...querystring } = params;
  1463. cluster_name = encodePathParam(clusterName, cluster_name);
  1464. let path = ['', '_plugins', '_security', 'api', 'nodesdn', cluster_name]
  1465. .filter((c) => c != null)
  1466. .join('/');
  1467. method = method || 'PUT';
  1468. body = body || '';
  1469. querystring = snakeCaseKeys(null, snakeCase, querystring);
  1470. return this.transport.request({ method, path, body, querystring }, options, callback);
  1471. };
  1472. Object.defineProperties(SecurityApi.prototype, {
  1473. change_password: {
  1474. get() {
  1475. return this.changePassword;
  1476. },
  1477. },
  1478. create_action_group: {
  1479. get() {
  1480. return this.createActionGroup;
  1481. },
  1482. },
  1483. create_role: {
  1484. get() {
  1485. return this.createRole;
  1486. },
  1487. },
  1488. create_role_mapping: {
  1489. get() {
  1490. return this.createRoleMapping;
  1491. },
  1492. },
  1493. create_tenant: {
  1494. get() {
  1495. return this.createTenant;
  1496. },
  1497. },
  1498. create_user: {
  1499. get() {
  1500. return this.createUser;
  1501. },
  1502. },
  1503. delete_action_group: {
  1504. get() {
  1505. return this.deleteActionGroup;
  1506. },
  1507. },
  1508. delete_distinguished_names: {
  1509. get() {
  1510. return this.deleteDistinguishedNames;
  1511. },
  1512. },
  1513. delete_role: {
  1514. get() {
  1515. return this.deleteRole;
  1516. },
  1517. },
  1518. delete_role_mapping: {
  1519. get() {
  1520. return this.deleteRoleMapping;
  1521. },
  1522. },
  1523. delete_tenant: {
  1524. get() {
  1525. return this.deleteTenant;
  1526. },
  1527. },
  1528. delete_user: {
  1529. get() {
  1530. return this.deleteUser;
  1531. },
  1532. },
  1533. flush_cache: {
  1534. get() {
  1535. return this.flushCache;
  1536. },
  1537. },
  1538. get_account_details: {
  1539. get() {
  1540. return this.getAccountDetails;
  1541. },
  1542. },
  1543. get_action_group: {
  1544. get() {
  1545. return this.getActionGroup;
  1546. },
  1547. },
  1548. get_action_groups: {
  1549. get() {
  1550. return this.getActionGroups;
  1551. },
  1552. },
  1553. get_audit_configuration: {
  1554. get() {
  1555. return this.getAuditConfiguration;
  1556. },
  1557. },
  1558. get_certificates: {
  1559. get() {
  1560. return this.getCertificates;
  1561. },
  1562. },
  1563. get_configuration: {
  1564. get() {
  1565. return this.getConfiguration;
  1566. },
  1567. },
  1568. get_distinguished_names: {
  1569. get() {
  1570. return this.getDistinguishedNames;
  1571. },
  1572. },
  1573. get_role: {
  1574. get() {
  1575. return this.getRole;
  1576. },
  1577. },
  1578. get_role_mapping: {
  1579. get() {
  1580. return this.getRoleMapping;
  1581. },
  1582. },
  1583. get_role_mappings: {
  1584. get() {
  1585. return this.getRoleMappings;
  1586. },
  1587. },
  1588. get_roles: {
  1589. get() {
  1590. return this.getRoles;
  1591. },
  1592. },
  1593. get_tenant: {
  1594. get() {
  1595. return this.getTenant;
  1596. },
  1597. },
  1598. get_tenants: {
  1599. get() {
  1600. return this.getTenants;
  1601. },
  1602. },
  1603. get_user: {
  1604. get() {
  1605. return this.getUser;
  1606. },
  1607. },
  1608. get_users: {
  1609. get() {
  1610. return this.getUsers;
  1611. },
  1612. },
  1613. patch_action_group: {
  1614. get() {
  1615. return this.patchActionGroup;
  1616. },
  1617. },
  1618. patch_action_groups: {
  1619. get() {
  1620. return this.patchActionGroups;
  1621. },
  1622. },
  1623. patch_audit_configuration: {
  1624. get() {
  1625. return this.patchAuditConfiguration;
  1626. },
  1627. },
  1628. patch_configuration: {
  1629. get() {
  1630. return this.patchConfiguration;
  1631. },
  1632. },
  1633. patch_distinguished_names: {
  1634. get() {
  1635. return this.patchDistinguishedNames;
  1636. },
  1637. },
  1638. patch_role: {
  1639. get() {
  1640. return this.patchRole;
  1641. },
  1642. },
  1643. patch_role_mapping: {
  1644. get() {
  1645. return this.patchRoleMapping;
  1646. },
  1647. },
  1648. patch_role_mappings: {
  1649. get() {
  1650. return this.patchRoleMappings;
  1651. },
  1652. },
  1653. patch_roles: {
  1654. get() {
  1655. return this.patchRoles;
  1656. },
  1657. },
  1658. patch_tenant: {
  1659. get() {
  1660. return this.patchTenant;
  1661. },
  1662. },
  1663. patch_tenants: {
  1664. get() {
  1665. return this.patchTenants;
  1666. },
  1667. },
  1668. patch_user: {
  1669. get() {
  1670. return this.patchUser;
  1671. },
  1672. },
  1673. patch_users: {
  1674. get() {
  1675. return this.patchUsers;
  1676. },
  1677. },
  1678. reload_http_certificates: {
  1679. get() {
  1680. return this.reloadHttpCertificates;
  1681. },
  1682. },
  1683. reload_transport_certificates: {
  1684. get() {
  1685. return this.reloadTransportCertificates;
  1686. },
  1687. },
  1688. update_audit_configuration: {
  1689. get() {
  1690. return this.updateAuditConfiguration;
  1691. },
  1692. },
  1693. update_configuration: {
  1694. get() {
  1695. return this.updateConfiguration;
  1696. },
  1697. },
  1698. update_distinguished_names: {
  1699. get() {
  1700. return this.updateDistinguishedNames;
  1701. },
  1702. },
  1703. });
  1704. module.exports = SecurityApi;