From 394a84491236efe7621534a3fef60b0d281fb55c Mon Sep 17 00:00:00 2001 From: Theo Nam Truong Date: Mon, 2 Oct 2023 16:09:31 -0600 Subject: [PATCH] Added Security Namespace (#606) Signed-off-by: Theo Truong --- CHANGELOG.md | 3 +- api/api/security.js | 1954 +++++++++++++++++ api/index.js | 11 + api/new.d.ts | 885 ++++++++ api/utils.js | 14 +- .../helpers-secure/security.test.js | 64 + 6 files changed, 2929 insertions(+), 2 deletions(-) create mode 100644 api/api/security.js create mode 100644 test/integration/helpers-secure/security.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 261a36737..ad6b0afeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased] ### Added +- Added Security API ### Dependencies - Bumps `rimraf` from 5.0.0 to 5.0.5 - Bumps `eslint` from 8.41.0 to 8.50.0 @@ -180,4 +181,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) [2.1.0]: https://github.com/opensearch-project/opensearch-js/releases/tag/2.1.0 [2.2.0]: https://github.com/opensearch-project/opensearch-js/releases/tag/2.2.0 [2.2.1]: https://github.com/opensearch-project/opensearch-js/releases/tag/2.2.1 -[Unreleased]: https://github.com/opensearch-project/opensearch-js/compare/2.2.1...HEAD \ No newline at end of file +[Unreleased]: https://github.com/opensearch-project/opensearch-js/compare/2.2.1...HEAD diff --git a/api/api/security.js b/api/api/security.js new file mode 100644 index 000000000..1a8c31f2e --- /dev/null +++ b/api/api/security.js @@ -0,0 +1,1954 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + * + */ + +'use strict'; + +/** @namespace API-Security */ + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { + handleError, + snakeCaseKeys, + encodePathParam, + normalizeArguments, + kConfigurationError, +} = require('../utils'); +const snakeCase = {}; + +function SecurityApi(transport, ConfigurationError) { + this.transport = transport; + this[kConfigurationError] = ConfigurationError; +} + +/** + * Changes the password for the current user. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#change-password - Security - Change Password} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {Object} params.body + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.changePassword = function securityChangePasswordApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.body == null) { + const err = new this[kConfigurationError]('Missing required parameter: body'); + return handleError(err, callback); + } + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'account'].filter((c) => c != null).join('/'); + method = method || 'PUT'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Creates or replaces the specified action group. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#create-action-group - Security - Create Action Group} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} params.action_group - The name of the action group to create or replace + * @param {Object} params.body + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.createActionGroup = function securityCreateActionGroupApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.actionGroup == null && params.action_group == null) { + const err = new this[kConfigurationError]('Missing required parameter: action_group'); + return handleError(err, callback); + } + if (params.body == null) { + const err = new this[kConfigurationError]('Missing required parameter: body'); + return handleError(err, callback); + } + + let { method, body, actionGroup, action_group, ...querystring } = params; + + action_group = encodePathParam(actionGroup, action_group); + + let path = ['', '_plugins', '_security', 'api', 'actiongroups', action_group] + .filter((c) => c != null) + .join('/'); + method = method || 'PUT'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Creates or replaces the specified role. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#create-role - Security - Create Role} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} params.role + * @param {Object} params.body + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.createRole = function securityCreateRoleApi(params, options, callback) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.role == null) { + const err = new this[kConfigurationError]('Missing required parameter: role'); + return handleError(err, callback); + } + if (params.body == null) { + const err = new this[kConfigurationError]('Missing required parameter: body'); + return handleError(err, callback); + } + + let { method, body, role, ...querystring } = params; + + role = encodePathParam(role); + + let path = ['', '_plugins', '_security', 'api', 'roles', role].filter((c) => c != null).join('/'); + method = method || 'PUT'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Creates or replaces the specified role mapping. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#create-role-mapping - Security - Create Role Mapping} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} params.role + * @param {Object} params.body + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.createRoleMapping = function securityCreateRoleMappingApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.role == null) { + const err = new this[kConfigurationError]('Missing required parameter: role'); + return handleError(err, callback); + } + if (params.body == null) { + const err = new this[kConfigurationError]('Missing required parameter: body'); + return handleError(err, callback); + } + + let { method, body, role, ...querystring } = params; + + role = encodePathParam(role); + + let path = ['', '_plugins', '_security', 'api', 'rolesmapping', role] + .filter((c) => c != null) + .join('/'); + method = method || 'PUT'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Creates or replaces the specified tenant. + *
See Also: {@link https://opensearch.org/docs/2.7/security/access-control/api/#create-tenant - Security - Create Tenant} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} params.tenant + * @param {Object} params.body + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.createTenant = function securityCreateTenantApi(params, options, callback) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.tenant == null) { + const err = new this[kConfigurationError]('Missing required parameter: tenant'); + return handleError(err, callback); + } + if (params.body == null) { + const err = new this[kConfigurationError]('Missing required parameter: body'); + return handleError(err, callback); + } + + let { method, body, tenant, ...querystring } = params; + + tenant = encodePathParam(tenant); + + let path = ['', '_plugins', '_security', 'api', 'tenants', tenant] + .filter((c) => c != null) + .join('/'); + method = method || 'PUT'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Creates or replaces the specified user. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#create-user - Security - Create User} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} params.username + * @param {Object} params.body + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.createUser = function securityCreateUserApi(params, options, callback) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.username == null) { + const err = new this[kConfigurationError]('Missing required parameter: username'); + return handleError(err, callback); + } + if (params.body == null) { + const err = new this[kConfigurationError]('Missing required parameter: body'); + return handleError(err, callback); + } + + let { method, body, username, ...querystring } = params; + + username = encodePathParam(username); + + let path = ['', '_plugins', '_security', 'api', 'internalusers', username] + .filter((c) => c != null) + .join('/'); + method = method || 'PUT'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Delete a specified action group. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#delete-action-group - Security - Delete Action Group} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} params.action_group - Action group to delete. + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.deleteActionGroup = function securityDeleteActionGroupApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.actionGroup == null && params.action_group == null) { + const err = new this[kConfigurationError]('Missing required parameter: action_group'); + return handleError(err, callback); + } + + let { method, body, actionGroup, action_group, ...querystring } = params; + + action_group = encodePathParam(actionGroup, action_group); + + let path = ['', '_plugins', '_security', 'api', 'actiongroups', action_group] + .filter((c) => c != null) + .join('/'); + method = method || 'DELETE'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Deletes all distinguished names in the specified cluster’s or node’s allow list. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#delete-distinguished-names - Security - Delete Distinguished Names} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} params.cluster_name + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.deleteDistinguishedNames = function securityDeleteDistinguishedNamesApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.clusterName == null && params.cluster_name == null) { + const err = new this[kConfigurationError]('Missing required parameter: cluster_name'); + return handleError(err, callback); + } + + let { method, body, clusterName, cluster_name, ...querystring } = params; + + cluster_name = encodePathParam(clusterName, cluster_name); + + let path = ['', '_plugins', '_security', 'api', 'nodesdn', cluster_name] + .filter((c) => c != null) + .join('/'); + method = method || 'DELETE'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Delete the specified role. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#delete-role - Security - Delete Role} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} params.role + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.deleteRole = function securityDeleteRoleApi(params, options, callback) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.role == null) { + const err = new this[kConfigurationError]('Missing required parameter: role'); + return handleError(err, callback); + } + + let { method, body, role, ...querystring } = params; + + role = encodePathParam(role); + + let path = ['', '_plugins', '_security', 'api', 'roles', role].filter((c) => c != null).join('/'); + method = method || 'DELETE'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Deletes the specified role mapping. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#delete-role-mapping - Security - Delete Role Mapping} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} params.role + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.deleteRoleMapping = function securityDeleteRoleMappingApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.role == null) { + const err = new this[kConfigurationError]('Missing required parameter: role'); + return handleError(err, callback); + } + + let { method, body, role, ...querystring } = params; + + role = encodePathParam(role); + + let path = ['', '_plugins', '_security', 'api', 'rolesmapping', role] + .filter((c) => c != null) + .join('/'); + method = method || 'DELETE'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Delete the specified tenant. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#delete-action-group - Security - Delete Tenant} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} params.tenant + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.deleteTenant = function securityDeleteTenantApi(params, options, callback) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.tenant == null) { + const err = new this[kConfigurationError]('Missing required parameter: tenant'); + return handleError(err, callback); + } + + let { method, body, tenant, ...querystring } = params; + + tenant = encodePathParam(tenant); + + let path = ['', '_plugins', '_security', 'api', 'tenants', tenant] + .filter((c) => c != null) + .join('/'); + method = method || 'DELETE'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Delete the specified user. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#delete-user - Security - Delete User} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} params.username + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.deleteUser = function securityDeleteUserApi(params, options, callback) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.username == null) { + const err = new this[kConfigurationError]('Missing required parameter: username'); + return handleError(err, callback); + } + + let { method, body, username, ...querystring } = params; + + username = encodePathParam(username); + + let path = ['', '_plugins', '_security', 'api', 'internalusers', username] + .filter((c) => c != null) + .join('/'); + method = method || 'DELETE'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Flushes the Security plugin user, authentication, and authorization cache. + *
See Also: {@link https://opensearch.org/docs/2.7/security/access-control/api/#flush-cache - Security - Flush Cache} + * + * @memberOf API-Security + * + * @param {Object} params + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.flushCache = function securityFlushCacheApi(params, options, callback) { + [params, options, callback] = normalizeArguments(params, options, callback); + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'cache'].filter((c) => c != null).join('/'); + method = method || 'DELETE'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Returns account details for the current user. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#get-account-details - Security - Get Account Details} + * + * @memberOf API-Security + * + * @param {Object} params + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.getAccountDetails = function securityGetAccountDetailsApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'account'].filter((c) => c != null).join('/'); + method = method || 'GET'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Retrieves one action group. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#get-action-group - Security - Get Action Group} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} params.action_group - Action group to retrieve. + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.getActionGroup = function securityGetActionGroupApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.actionGroup == null && params.action_group == null) { + const err = new this[kConfigurationError]('Missing required parameter: action_group'); + return handleError(err, callback); + } + + let { method, body, actionGroup, action_group, ...querystring } = params; + + action_group = encodePathParam(actionGroup, action_group); + + let path = ['', '_plugins', '_security', 'api', 'actiongroups', action_group] + .filter((c) => c != null) + .join('/'); + method = method || 'GET'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Retrieves all action groups. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#get-action-groups - Security - Get Action Groups} + * + * @memberOf API-Security + * + * @param {Object} params + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.getActionGroups = function securityGetActionGroupsApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'actiongroups'] + .filter((c) => c != null) + .join('/'); + method = method || 'GET'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Retrieves the audit configuration. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#audit-logs - Security - Get Audit Configuration} + * + * @memberOf API-Security + * + * @param {Object} params + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.getAuditConfiguration = function securityGetAuditConfigurationApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'audit'].filter((c) => c != null).join('/'); + method = method || 'GET'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Retrieves the cluster’s security certificates. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#get-certificates - Security - Get Certificates} + * + * @memberOf API-Security + * + * @param {Object} params + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.getCertificates = function securityGetCertificatesApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'ssl', 'certs'] + .filter((c) => c != null) + .join('/'); + method = method || 'GET'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Returns the current Security plugin configuration in JSON format. + *
See Also: {@link https://opensearch.org/docs/2.7/security/access-control/api/#get-configuration - Security - Get Configuration} + * + * @memberOf API-Security + * + * @param {Object} params + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.getConfiguration = function securityGetConfigurationApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'securityconfig'] + .filter((c) => c != null) + .join('/'); + method = method || 'GET'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Retrieves all distinguished names in the allow list. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#get-distinguished-names - Security - Get Distinguished Names} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} [params.cluster_name] + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.getDistinguishedNames = function securityGetDistinguishedNamesApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + let { method, body, clusterName, cluster_name, ...querystring } = params; + + cluster_name = encodePathParam(clusterName, cluster_name); + + let path = ['', '_plugins', '_security', 'api', 'nodesdn', cluster_name] + .filter((c) => c != null) + .join('/'); + method = method || 'GET'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Retrieves one role. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#get-role - Security - Get Role} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} params.role + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.getRole = function securityGetRoleApi(params, options, callback) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.role == null) { + const err = new this[kConfigurationError]('Missing required parameter: role'); + return handleError(err, callback); + } + + let { method, body, role, ...querystring } = params; + + role = encodePathParam(role); + + let path = ['', '_plugins', '_security', 'api', 'roles', role].filter((c) => c != null).join('/'); + method = method || 'GET'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Retrieves one role mapping. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#get-role-mapping - Security - Get Role Mapping} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} params.role + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.getRoleMapping = function securityGetRoleMappingApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.role == null) { + const err = new this[kConfigurationError]('Missing required parameter: role'); + return handleError(err, callback); + } + + let { method, body, role, ...querystring } = params; + + role = encodePathParam(role); + + let path = ['', '_plugins', '_security', 'api', 'rolesmapping', role] + .filter((c) => c != null) + .join('/'); + method = method || 'GET'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Retrieves all role mappings. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#get-role-mappings - Security - Get Role Mappings} + * + * @memberOf API-Security + * + * @param {Object} params + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.getRoleMappings = function securityGetRoleMappingsApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'rolesmapping'] + .filter((c) => c != null) + .join('/'); + method = method || 'GET'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Retrieves all roles. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#get-roles - Security - Get Roles} + * + * @memberOf API-Security + * + * @param {Object} params + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.getRoles = function securityGetRolesApi(params, options, callback) { + [params, options, callback] = normalizeArguments(params, options, callback); + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'roles'].filter((c) => c != null).join('/'); + method = method || 'GET'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Retrieves one tenant. + *
See Also: {@link https://opensearch.org/docs/2.7/security/access-control/api/#get-tenant - Security - Get Tenant} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} params.tenant + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.getTenant = function securityGetTenantApi(params, options, callback) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.tenant == null) { + const err = new this[kConfigurationError]('Missing required parameter: tenant'); + return handleError(err, callback); + } + + let { method, body, tenant, ...querystring } = params; + + tenant = encodePathParam(tenant); + + let path = ['', '_plugins', '_security', 'api', 'tenants', tenant] + .filter((c) => c != null) + .join('/'); + method = method || 'GET'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Retrieves all tenants. + *
See Also: {@link https://opensearch.org/docs/2.7/security/access-control/api/#get-tenants - Security - Get Tenants} + * + * @memberOf API-Security + * + * @param {Object} params + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.getTenants = function securityGetTenantsApi(params, options, callback) { + [params, options, callback] = normalizeArguments(params, options, callback); + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'tenants'].filter((c) => c != null).join('/'); + method = method || 'GET'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Retrieve one internal user. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#get-user - Security - Get User} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} params.username + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.getUser = function securityGetUserApi(params, options, callback) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.username == null) { + const err = new this[kConfigurationError]('Missing required parameter: username'); + return handleError(err, callback); + } + + let { method, body, username, ...querystring } = params; + + username = encodePathParam(username); + + let path = ['', '_plugins', '_security', 'api', 'internalusers', username] + .filter((c) => c != null) + .join('/'); + method = method || 'GET'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Retrieve all internal users. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#get-users - Security - Get Users} + * + * @memberOf API-Security + * + * @param {Object} params + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.getUsers = function securityGetUsersApi(params, options, callback) { + [params, options, callback] = normalizeArguments(params, options, callback); + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'internalusers'] + .filter((c) => c != null) + .join('/'); + method = method || 'GET'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Checks to see if the Security plugin is up and running. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#health-check - Security - Health} + * + * @memberOf API-Security + * + * @param {Object} params + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.health = function securityHealthApi(params, options, callback) { + [params, options, callback] = normalizeArguments(params, options, callback); + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'health'].filter((c) => c != null).join('/'); + method = method || 'GET'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Updates individual attributes of an action group. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#patch-action-group - Security - Patch Action Group} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} params.action_group + * @param {Object} params.body + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.patchActionGroup = function securityPatchActionGroupApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.actionGroup == null && params.action_group == null) { + const err = new this[kConfigurationError]('Missing required parameter: action_group'); + return handleError(err, callback); + } + if (params.body == null) { + const err = new this[kConfigurationError]('Missing required parameter: body'); + return handleError(err, callback); + } + + let { method, body, actionGroup, action_group, ...querystring } = params; + + action_group = encodePathParam(actionGroup, action_group); + + let path = ['', '_plugins', '_security', 'api', 'actiongroups', action_group] + .filter((c) => c != null) + .join('/'); + method = method || 'PATCH'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Creates, updates, or deletes multiple action groups in a single call. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#patch-action-groups - Security - Patch Action Groups} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {Object} params.body + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.patchActionGroups = function securityPatchActionGroupsApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.body == null) { + const err = new this[kConfigurationError]('Missing required parameter: body'); + return handleError(err, callback); + } + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'actiongroups'] + .filter((c) => c != null) + .join('/'); + method = method || 'PATCH'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * A PATCH call is used to update specified fields in the audit configuration. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#audit-logs - Security - Patch Audit Configuration} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {Object} params.body + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.patchAuditConfiguration = function securityPatchAuditConfigurationApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.body == null) { + const err = new this[kConfigurationError]('Missing required parameter: body'); + return handleError(err, callback); + } + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'audit'].filter((c) => c != null).join('/'); + method = method || 'PATCH'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * A PATCH call is used to update the existing configuration using the REST API. + *
See Also: {@link https://opensearch.org/docs/2.7/security/access-control/api/#patch-configuration - Security - Patch Configuration} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {Object} params.body + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.patchConfiguration = function securityPatchConfigurationApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.body == null) { + const err = new this[kConfigurationError]('Missing required parameter: body'); + return handleError(err, callback); + } + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'securityconfig'] + .filter((c) => c != null) + .join('/'); + method = method || 'PATCH'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Bulk update of distinguished names. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#update-all-distinguished-names - Security - Patch Distinguished Names} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {Object} params.body + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.patchDistinguishedNames = function securityPatchDistinguishedNamesApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.body == null) { + const err = new this[kConfigurationError]('Missing required parameter: body'); + return handleError(err, callback); + } + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'nodesdn'].filter((c) => c != null).join('/'); + method = method || 'PATCH'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Updates individual attributes of a role. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#patch-role - Security - Patch Role} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} params.role + * @param {Object} params.body + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.patchRole = function securityPatchRoleApi(params, options, callback) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.role == null) { + const err = new this[kConfigurationError]('Missing required parameter: role'); + return handleError(err, callback); + } + if (params.body == null) { + const err = new this[kConfigurationError]('Missing required parameter: body'); + return handleError(err, callback); + } + + let { method, body, role, ...querystring } = params; + + role = encodePathParam(role); + + let path = ['', '_plugins', '_security', 'api', 'roles', role].filter((c) => c != null).join('/'); + method = method || 'PATCH'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Updates individual attributes of a role mapping. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#patch-role-mapping - Security - Patch Role Mapping} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} params.role + * @param {Object} params.body + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.patchRoleMapping = function securityPatchRoleMappingApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.role == null) { + const err = new this[kConfigurationError]('Missing required parameter: role'); + return handleError(err, callback); + } + if (params.body == null) { + const err = new this[kConfigurationError]('Missing required parameter: body'); + return handleError(err, callback); + } + + let { method, body, role, ...querystring } = params; + + role = encodePathParam(role); + + let path = ['', '_plugins', '_security', 'api', 'rolesmapping', role] + .filter((c) => c != null) + .join('/'); + method = method || 'PATCH'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Creates or updates multiple role mappings in a single call. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#patch-role-mappings - Security - Patch Role Mappings} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {Object} params.body + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.patchRoleMappings = function securityPatchRoleMappingsApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.body == null) { + const err = new this[kConfigurationError]('Missing required parameter: body'); + return handleError(err, callback); + } + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'rolesmapping'] + .filter((c) => c != null) + .join('/'); + method = method || 'PATCH'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Creates, updates, or deletes multiple roles in a single call. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#patch-roles - Security - Patch Roles} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {Object} params.body + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.patchRoles = function securityPatchRolesApi(params, options, callback) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.body == null) { + const err = new this[kConfigurationError]('Missing required parameter: body'); + return handleError(err, callback); + } + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'roles'].filter((c) => c != null).join('/'); + method = method || 'PATCH'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Add, delete, or modify a single tenant. + *
See Also: {@link https://opensearch.org/docs/2.7/security/access-control/api/#patch-tenant - Security - Patch Tenant} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} params.tenant + * @param {Object} params.body + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.patchTenant = function securityPatchTenantApi(params, options, callback) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.tenant == null) { + const err = new this[kConfigurationError]('Missing required parameter: tenant'); + return handleError(err, callback); + } + if (params.body == null) { + const err = new this[kConfigurationError]('Missing required parameter: body'); + return handleError(err, callback); + } + + let { method, body, tenant, ...querystring } = params; + + tenant = encodePathParam(tenant); + + let path = ['', '_plugins', '_security', 'api', 'tenants', tenant] + .filter((c) => c != null) + .join('/'); + method = method || 'PATCH'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Add, delete, or modify multiple tenants in a single call. + *
See Also: {@link https://opensearch.org/docs/2.7/security/access-control/api/#patch-tenants - Security - Patch Tenants} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {Object} params.body + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.patchTenants = function securityPatchTenantsApi(params, options, callback) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.body == null) { + const err = new this[kConfigurationError]('Missing required parameter: body'); + return handleError(err, callback); + } + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'tenants'].filter((c) => c != null).join('/'); + method = method || 'PATCH'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Updates individual attributes of an internal user. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#patch-user - Security - Patch User} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} params.username + * @param {Object} params.body + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.patchUser = function securityPatchUserApi(params, options, callback) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.username == null) { + const err = new this[kConfigurationError]('Missing required parameter: username'); + return handleError(err, callback); + } + if (params.body == null) { + const err = new this[kConfigurationError]('Missing required parameter: body'); + return handleError(err, callback); + } + + let { method, body, username, ...querystring } = params; + + username = encodePathParam(username); + + let path = ['', '_plugins', '_security', 'api', 'internalusers', username] + .filter((c) => c != null) + .join('/'); + method = method || 'PATCH'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Creates, updates, or deletes multiple internal users in a single call. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#patch-users - Security - Patch Users} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {Object} params.body + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.patchUsers = function securityPatchUsersApi(params, options, callback) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.body == null) { + const err = new this[kConfigurationError]('Missing required parameter: body'); + return handleError(err, callback); + } + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'internalusers'] + .filter((c) => c != null) + .join('/'); + method = method || 'PATCH'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Reload HTTP layer communication certificates. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#reload-http-certificates - Security - Reload Http Certificates} + * + * @memberOf API-Security + * + * @param {Object} params + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.reloadHttpCertificates = function securityReloadHttpCertificatesApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'ssl', 'http', 'reloadcerts'] + .filter((c) => c != null) + .join('/'); + method = method || 'PUT'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Reload transport layer communication certificates. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#reload-transport-certificates - Security - Reload Transport Certificates} + * + * @memberOf API-Security + * + * @param {Object} params + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.reloadTransportCertificates = function securityReloadTransportCertificatesApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'ssl', 'transport', 'reloadcerts'] + .filter((c) => c != null) + .join('/'); + method = method || 'PUT'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Updates the audit configuration. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#audit-logs - Security - Update Audit Configuration} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {Object} params.body + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.updateAuditConfiguration = function securityUpdateAuditConfigurationApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.body == null) { + const err = new this[kConfigurationError]('Missing required parameter: body'); + return handleError(err, callback); + } + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'audit', 'config'] + .filter((c) => c != null) + .join('/'); + method = method || 'PUT'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Adds or updates the existing configuration using the REST API. + *
See Also: {@link https://opensearch.org/docs/2.7/security/access-control/api/#update-configuration - Security - Update Configuration} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {Object} params.body + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.updateConfiguration = function securityUpdateConfigurationApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.body == null) { + const err = new this[kConfigurationError]('Missing required parameter: body'); + return handleError(err, callback); + } + + let { method, body, ...querystring } = params; + + let path = ['', '_plugins', '_security', 'api', 'securityconfig', 'config'] + .filter((c) => c != null) + .join('/'); + method = method || 'PUT'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +/** + * Adds or updates the specified distinguished names in the cluster’s or node’s allow list. + *
See Also: {@link https://opensearch.org/docs/latest/security/access-control/api/#update-distinguished-names - Security - Update Distinguished Names} + * + * @memberOf API-Security + * + * @param {Object} params + * @param {string} params.cluster_name + * @param {Object} [params.body] + * + * @param {Object} options - Options for {@link Transport#request} + * @param {function} callback - Callback that handles errors and response + * + * @returns {{abort: function(), then: function(), catch: function()}|Promise|*} + */ +SecurityApi.prototype.updateDistinguishedNames = function securityUpdateDistinguishedNamesApi( + params, + options, + callback +) { + [params, options, callback] = normalizeArguments(params, options, callback); + + if (params.clusterName == null && params.cluster_name == null) { + const err = new this[kConfigurationError]('Missing required parameter: cluster_name'); + return handleError(err, callback); + } + + let { method, body, clusterName, cluster_name, ...querystring } = params; + + cluster_name = encodePathParam(clusterName, cluster_name); + + let path = ['', '_plugins', '_security', 'api', 'nodesdn', cluster_name] + .filter((c) => c != null) + .join('/'); + method = method || 'PUT'; + body = body || ''; + querystring = snakeCaseKeys(null, snakeCase, querystring); + + return this.transport.request({ method, path, body, querystring }, options, callback); +}; + +Object.defineProperties(SecurityApi.prototype, { + change_password: { + get() { + return this.changePassword; + }, + }, + create_action_group: { + get() { + return this.createActionGroup; + }, + }, + create_role: { + get() { + return this.createRole; + }, + }, + create_role_mapping: { + get() { + return this.createRoleMapping; + }, + }, + create_tenant: { + get() { + return this.createTenant; + }, + }, + create_user: { + get() { + return this.createUser; + }, + }, + delete_action_group: { + get() { + return this.deleteActionGroup; + }, + }, + delete_distinguished_names: { + get() { + return this.deleteDistinguishedNames; + }, + }, + delete_role: { + get() { + return this.deleteRole; + }, + }, + delete_role_mapping: { + get() { + return this.deleteRoleMapping; + }, + }, + delete_tenant: { + get() { + return this.deleteTenant; + }, + }, + delete_user: { + get() { + return this.deleteUser; + }, + }, + flush_cache: { + get() { + return this.flushCache; + }, + }, + get_account_details: { + get() { + return this.getAccountDetails; + }, + }, + get_action_group: { + get() { + return this.getActionGroup; + }, + }, + get_action_groups: { + get() { + return this.getActionGroups; + }, + }, + get_audit_configuration: { + get() { + return this.getAuditConfiguration; + }, + }, + get_certificates: { + get() { + return this.getCertificates; + }, + }, + get_configuration: { + get() { + return this.getConfiguration; + }, + }, + get_distinguished_names: { + get() { + return this.getDistinguishedNames; + }, + }, + get_role: { + get() { + return this.getRole; + }, + }, + get_role_mapping: { + get() { + return this.getRoleMapping; + }, + }, + get_role_mappings: { + get() { + return this.getRoleMappings; + }, + }, + get_roles: { + get() { + return this.getRoles; + }, + }, + get_tenant: { + get() { + return this.getTenant; + }, + }, + get_tenants: { + get() { + return this.getTenants; + }, + }, + get_user: { + get() { + return this.getUser; + }, + }, + get_users: { + get() { + return this.getUsers; + }, + }, + patch_action_group: { + get() { + return this.patchActionGroup; + }, + }, + patch_action_groups: { + get() { + return this.patchActionGroups; + }, + }, + patch_audit_configuration: { + get() { + return this.patchAuditConfiguration; + }, + }, + patch_configuration: { + get() { + return this.patchConfiguration; + }, + }, + patch_distinguished_names: { + get() { + return this.patchDistinguishedNames; + }, + }, + patch_role: { + get() { + return this.patchRole; + }, + }, + patch_role_mapping: { + get() { + return this.patchRoleMapping; + }, + }, + patch_role_mappings: { + get() { + return this.patchRoleMappings; + }, + }, + patch_roles: { + get() { + return this.patchRoles; + }, + }, + patch_tenant: { + get() { + return this.patchTenant; + }, + }, + patch_tenants: { + get() { + return this.patchTenants; + }, + }, + patch_user: { + get() { + return this.patchUser; + }, + }, + patch_users: { + get() { + return this.patchUsers; + }, + }, + reload_http_certificates: { + get() { + return this.reloadHttpCertificates; + }, + }, + reload_transport_certificates: { + get() { + return this.reloadTransportCertificates; + }, + }, + update_audit_configuration: { + get() { + return this.updateAuditConfiguration; + }, + }, + update_configuration: { + get() { + return this.updateConfiguration; + }, + }, + update_distinguished_names: { + get() { + return this.updateDistinguishedNames; + }, + }, +}); +module.exports = SecurityApi; diff --git a/api/index.js b/api/index.js index 8f58c93f5..d98e3a280 100644 --- a/api/index.js +++ b/api/index.js @@ -71,6 +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 searchApi = require('./api/search'); const searchShardsApi = require('./api/search_shards'); const searchTemplateApi = require('./api/search_template'); @@ -91,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'); @@ -104,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; @@ -325,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) { diff --git a/api/new.d.ts b/api/new.d.ts index 782f06725..cf6aaef67 100644 --- a/api/new.d.ts +++ b/api/new.d.ts @@ -1946,6 +1946,891 @@ declare class Client { options: TransportRequestOptions, callback: callbackFn, TContext> ): TransportRequestCallback; + security: { + + changePassword( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + changePassword( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + changePassword( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + createActionGroup( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + createActionGroup( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + createActionGroup( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + createRole( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + createRole( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + createRole( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + createRoleMapping( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + createRoleMapping( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + createRoleMapping( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + createTenant( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + createTenant( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + createTenant( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + createUser( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + createUser( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + createUser( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + deleteActionGroup( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + deleteActionGroup( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + deleteActionGroup( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + deleteDistinguishedNames( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + deleteDistinguishedNames( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + deleteDistinguishedNames( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + deleteRole( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + deleteRole( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + deleteRole( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + deleteRoleMapping( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + deleteRoleMapping( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + deleteRoleMapping( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + deleteTenant( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + deleteTenant( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + deleteTenant( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + deleteUser( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + deleteUser( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + deleteUser( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + flushCache( + params?: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + flushCache( + callback: callbackFn + ): TransportRequestCallback; + flushCache( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + flushCache( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + flushCache( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + flushCache( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + flushCache( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + getAccountDetails( + params?: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getAccountDetails( + callback: callbackFn + ): TransportRequestCallback; + getAccountDetails( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getAccountDetails( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + getAccountDetails( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getAccountDetails( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getAccountDetails( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + getActionGroup( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getActionGroup( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getActionGroup( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + getActionGroups( + params?: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getActionGroups( + callback: callbackFn + ): TransportRequestCallback; + getActionGroups( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getActionGroups( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + getActionGroups( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getActionGroups( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getActionGroups( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + getAuditConfiguration( + params?: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getAuditConfiguration( + callback: callbackFn + ): TransportRequestCallback; + getAuditConfiguration( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getAuditConfiguration( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + getAuditConfiguration( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getAuditConfiguration( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getAuditConfiguration( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + getCertificates( + params?: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getCertificates( + callback: callbackFn + ): TransportRequestCallback; + getCertificates( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getCertificates( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + getCertificates( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getCertificates( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getCertificates( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + getConfiguration( + params?: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getConfiguration( + callback: callbackFn + ): TransportRequestCallback; + getConfiguration( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getConfiguration( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + getConfiguration( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getConfiguration( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getConfiguration( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + getDistinguishedNames( + params?: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getDistinguishedNames( + callback: callbackFn + ): TransportRequestCallback; + getDistinguishedNames( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getDistinguishedNames( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + getDistinguishedNames( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getDistinguishedNames( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getDistinguishedNames( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + getRole( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getRole( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getRole( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + getRoleMapping( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getRoleMapping( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getRoleMapping( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + getRoleMappings( + params?: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getRoleMappings( + callback: callbackFn + ): TransportRequestCallback; + getRoleMappings( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getRoleMappings( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + getRoleMappings( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getRoleMappings( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getRoleMappings( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + getRoles( + params?: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getRoles( + callback: callbackFn + ): TransportRequestCallback; + getRoles( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getRoles( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + getRoles( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getRoles( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getRoles( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + getTenant( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getTenant( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getTenant( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + getTenants( + params?: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getTenants( + callback: callbackFn + ): TransportRequestCallback; + getTenants( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getTenants( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + getTenants( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getTenants( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getTenants( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + getUser( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getUser( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getUser( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + getUsers( + params?: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getUsers( + callback: callbackFn + ): TransportRequestCallback; + getUsers( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getUsers( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + getUsers( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + getUsers( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + getUsers( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + health( + params?: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + health( + callback: callbackFn + ): TransportRequestCallback; + health( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + health( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + health( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + health( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + health( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + patchActionGroup( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + patchActionGroup( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + patchActionGroup( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + patchActionGroups( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + patchActionGroups( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + patchActionGroups( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + patchAuditConfiguration( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + patchAuditConfiguration( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + patchAuditConfiguration( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + patchConfiguration( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + patchConfiguration( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + patchConfiguration( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + patchDistinguishedNames( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + patchDistinguishedNames( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + patchDistinguishedNames( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + patchRole( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + patchRole( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + patchRole( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + patchRoleMapping( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + patchRoleMapping( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + patchRoleMapping( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + patchRoleMappings( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + patchRoleMappings( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + patchRoleMappings( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + patchRoles( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + patchRoles( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + patchRoles( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + patchTenant( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + patchTenant( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + patchTenant( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + patchTenants( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + patchTenants( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + patchTenants( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + patchUser( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + patchUser( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + patchUser( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + patchUsers( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + patchUsers( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + patchUsers( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + reloadHttpCertificates( + params?: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + reloadHttpCertificates( + callback: callbackFn + ): TransportRequestCallback; + reloadHttpCertificates( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + reloadHttpCertificates( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + reloadHttpCertificates( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + reloadHttpCertificates( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + reloadHttpCertificates( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + reloadTransportCertificates( + params?: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + reloadTransportCertificates( + callback: callbackFn + ): TransportRequestCallback; + reloadTransportCertificates( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + reloadTransportCertificates( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + reloadTransportCertificates( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + reloadTransportCertificates( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + reloadTransportCertificates( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + updateAuditConfiguration( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + updateAuditConfiguration( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + updateAuditConfiguration( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + updateConfiguration( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + updateConfiguration( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + updateConfiguration( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + updateDistinguishedNames( + params: TODO, + options?: TransportRequestOptions + ): TransportRequestPromise>; + updateDistinguishedNames( + params: TODO, + callback: callbackFn + ): TransportRequestCallback; + updateDistinguishedNames( + params: TODO, + options: TransportRequestOptions, + callback: callbackFn + ): TransportRequestCallback; + + }; shutdown: { deleteNode( params?: TODO, diff --git a/api/utils.js b/api/utils.js index 671e7b7bb..2fe703158 100644 --- a/api/utils.js +++ b/api/utils.js @@ -40,6 +40,11 @@ function handleError(err, callback) { return Promise.reject(err); } +function encodePathParam(camelName, snakeName = null) { + if (camelName == null && snakeName == null) return null; + return encodeURIComponent(snakeName || camelName); +} + function snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) { const target = {}; const keys = Object.keys(querystring); @@ -65,4 +70,11 @@ function normalizeArguments(params, options, callback) { function noop() {} -module.exports = { handleError, snakeCaseKeys, normalizeArguments, noop, kConfigurationError }; +module.exports = { + handleError, + snakeCaseKeys, + normalizeArguments, + noop, + kConfigurationError, + encodePathParam, +}; diff --git a/test/integration/helpers-secure/security.test.js b/test/integration/helpers-secure/security.test.js new file mode 100644 index 000000000..2b29d92c3 --- /dev/null +++ b/test/integration/helpers-secure/security.test.js @@ -0,0 +1,64 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + * + */ + +const { test } = require('tap'); +const { Client } = require('../../../'); + +const client = new Client({ + ssl: { + rejectUnauthorized: false, + }, + node: 'https://localhost:9200', + auth: { + username: 'admin', + password: 'admin', + }, +}); +const security = client.security; + +test('Security: User', async (t) => { + await security.createUser({ username: 'test_user', body: { password: 'aasodu23497@lksd' } }); + await security.getUser({ username: 'test_user' }); + await security.deleteUser({ username: 'test_user' }); + t.rejects(security.getUser({ username: 'test_user' })); +}); + +test('Security: Role', async (t) => { + await security.createRole({ role: 'test_role', body: { cluster_permissions: [] } }); + await security.getRole({ role: 'test_role' }); + await security.deleteRole({ role: 'test_role' }); + t.rejects(security.getRole({ role: 'test_role' })); +}); + +test('Security: RoleMapping', async (t) => { + await security.createRole({ role: 'test_role', body: { cluster_permissions: [] } }); + await security.createRoleMapping({ role: 'test_role', body: { users: [] } }); + await security.getRoleMapping({ role: 'test_role' }); + await security.deleteRoleMapping({ role: 'test_role' }); + t.rejects(security.getRoleMapping({ role: 'test_role' })); + await security.deleteRole({ role: 'test_role' }); +}); + +test('Security: ActionGroup', async (t) => { + await security.createActionGroup({ + action_group: 'test_action_group', + body: { allowed_actions: [] }, + }); + await security.getActionGroup({ action_group: 'test_action_group' }); // found + await security.deleteActionGroup({ action_group: 'test_action_group' }); + t.rejects(security.getActionGroup({ action_group: 'test_action_group' })); // not found +}); + +test('Security: Tenant', async (t) => { + await security.createTenant({ tenant: 'test_tenant', body: { description: 'test_tenant' } }); + await security.getTenant({ tenant: 'test_tenant' }); + await security.deleteTenant({ tenant: 'test_tenant' }); + t.rejects(security.getTenant({ tenant: 'test_tenant' })); +});