UNPKG

@ibm-cloud/secrets-manager

Version:
1,073 lines 323 kB
"use strict"; /** * (C) Copyright IBM Corp. 2025. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __generator = (this && this.__generator) || function (thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (g && (g = 0, op[0] && (_ = 0)), _) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; /** * IBM OpenAPI SDK Code Generator Version: 3.104.0-b4a47c49-20250418-184351 */ /* eslint-disable max-classes-per-file */ /* eslint-disable no-await-in-loop */ var extend = require("extend"); var ibm_cloud_sdk_core_1 = require("ibm-cloud-sdk-core"); var common_1 = require("../lib/common"); /** * With IBM Cloud® Secrets Manager, you can create, lease, and centrally manage secrets that are used in IBM Cloud * services or your custom-built applications. * * API Version: 2.0.0 * See: https://cloud.ibm.com/docs/secrets-manager */ var SecretsManagerV2 = /** @class */ (function (_super) { __extends(SecretsManagerV2, _super); /** * Construct a SecretsManagerV2 object. * * @param {Object} options - Options for the service. * @param {string} [options.serviceUrl] - The base URL for the service * @param {OutgoingHttpHeaders} [options.headers] - Default headers that shall be included with every request to the service. * @param {Authenticator} options.authenticator - The Authenticator object used to authenticate requests to the service * @constructor * @returns {SecretsManagerV2} */ function SecretsManagerV2(options) { var _this = this; options = options || {}; _this = _super.call(this, options) || this; if (options.serviceUrl) { _this.setServiceUrl(options.serviceUrl); } else { _this.setServiceUrl(SecretsManagerV2.DEFAULT_SERVICE_URL); } return _this; } /** * Constructs a service URL by formatting the parameterized service URL. * * The parameterized service URL is: * 'https://{instance_id}.{region}.secrets-manager.appdomain.cloud' * * The default variable values are: * - 'instance_id': 'provide-here-your-smgr-instanceuuid' * - 'region': 'us-south' * * @param {Map<string, string>} | null providedUrlVariables Map from variable names to desired values. * If a variable is not provided in this map, * the default variable value will be used instead. * @returns {string} The formatted URL with all variable placeholders replaced by values. */ SecretsManagerV2.constructServiceUrl = function (providedUrlVariables) { return (0, ibm_cloud_sdk_core_1.constructServiceUrl)(SecretsManagerV2.PARAMETERIZED_SERVICE_URL, SecretsManagerV2.defaultUrlVariables, providedUrlVariables); }; /************************* * Factory method ************************/ /** * Constructs an instance of SecretsManagerV2 with passed in options and external configuration. * * @param {UserOptions} [options] - The parameters to send to the service. * @param {string} [options.serviceName] - The name of the service to configure * @param {Authenticator} [options.authenticator] - The Authenticator object used to authenticate requests to the service * @param {string} [options.serviceUrl] - The base URL for the service * @returns {SecretsManagerV2} */ SecretsManagerV2.newInstance = function (options) { options = options || {}; if (!options.serviceName) { options.serviceName = this.DEFAULT_SERVICE_NAME; } if (!options.authenticator) { options.authenticator = (0, ibm_cloud_sdk_core_1.getAuthenticatorFromEnvironment)(options.serviceName); } var service = new SecretsManagerV2(options); service.configureService(options.serviceName); if (options.serviceUrl) { service.setServiceUrl(options.serviceUrl); } return service; }; /************************* * secretGroups ************************/ /** * Create a new secret group. * * Create a secret group that you can use to organize secrets and control who can access them. * * A successful request returns the ID value of the secret group, along with other properties. To learn more about * secret groups, check out the * [docs](https://cloud.ibm.com/docs/secrets-manager?topic=secrets-manager-secret-groups). * * @param {Object} params - The parameters to send to the service. * @param {string} params.name - The name of your secret group. * @param {string} [params.description] - An extended description of your secret group. * * To protect your privacy, do not use personal data, such as your name or location, as a description for your secret * group. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<SecretsManagerV2.Response<SecretsManagerV2.SecretGroup>>} */ SecretsManagerV2.prototype.createSecretGroup = function (params) { var _params = __assign({}, params); var _requiredParams = ['name']; var _validParams = ['name', 'description', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = { 'name': _params.name, 'description': _params.description, }; var sdkHeaders = (0, common_1.getSdkHeaders)(SecretsManagerV2.DEFAULT_SERVICE_NAME, 'v2', 'createSecretGroup'); var parameters = { options: { url: '/api/v2/secret_groups', method: 'POST', body: body, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', 'Content-Type': 'application/json', }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * List secret groups. * * List the secret groups that are available in your Secrets Manager instance. * * @param {Object} [params] - The parameters to send to the service. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<SecretsManagerV2.Response<SecretsManagerV2.SecretGroupCollection>>} */ SecretsManagerV2.prototype.listSecretGroups = function (params) { var _params = __assign({}, params); var _requiredParams = []; var _validParams = ['signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var sdkHeaders = (0, common_1.getSdkHeaders)(SecretsManagerV2.DEFAULT_SERVICE_NAME, 'v2', 'listSecretGroups'); var parameters = { options: { url: '/api/v2/secret_groups', method: 'GET', }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Get a secret group. * * Get the properties of an existing secret group by specifying the ID of the group. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - The UUID that uniquely identifies your secret group. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<SecretsManagerV2.Response<SecretsManagerV2.SecretGroup>>} */ SecretsManagerV2.prototype.getSecretGroup = function (params) { var _params = __assign({}, params); var _requiredParams = ['id']; var _validParams = ['id', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var path = { 'id': _params.id, }; var sdkHeaders = (0, common_1.getSdkHeaders)(SecretsManagerV2.DEFAULT_SERVICE_NAME, 'v2', 'getSecretGroup'); var parameters = { options: { url: '/api/v2/secret_groups/{id}', method: 'GET', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Update a secret group. * * Update the properties of an existing secret group, such as its name or description. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - The UUID that uniquely identifies your secret group. * @param {string} [params.name] - The name of your secret group. * @param {string} [params.description] - An extended description of your secret group. * * To protect your privacy, do not use personal data, such as your name or location, as a description for your secret * group. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<SecretsManagerV2.Response<SecretsManagerV2.SecretGroup>>} */ SecretsManagerV2.prototype.updateSecretGroup = function (params) { var _params = __assign({}, params); var _requiredParams = ['id']; var _validParams = ['id', 'name', 'description', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = { 'name': _params.name, 'description': _params.description, }; var path = { 'id': _params.id, }; var sdkHeaders = (0, common_1.getSdkHeaders)(SecretsManagerV2.DEFAULT_SERVICE_NAME, 'v2', 'updateSecretGroup'); var parameters = { options: { url: '/api/v2/secret_groups/{id}', method: 'PATCH', body: body, path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', 'Content-Type': 'application/merge-patch+json', }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Delete a secret group. * * Delete a secret group by specifying the ID of the secret group. * * **Note:** To delete a secret group, it must be empty. If you need to remove a secret group that contains secrets, * you must first delete the secrets that are associated with the group. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - The UUID that uniquely identifies your secret group. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<SecretsManagerV2.Response<SecretsManagerV2.EmptyObject>>} */ SecretsManagerV2.prototype.deleteSecretGroup = function (params) { var _params = __assign({}, params); var _requiredParams = ['id']; var _validParams = ['id', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var path = { 'id': _params.id, }; var sdkHeaders = (0, common_1.getSdkHeaders)(SecretsManagerV2.DEFAULT_SERVICE_NAME, 'v2', 'deleteSecretGroup'); var parameters = { options: { url: '/api/v2/secret_groups/{id}', method: 'DELETE', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, {}, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /************************* * secrets ************************/ /** * Create a new secret. * * Create a secret or import an existing value that you can use to access or authenticate to a protected resource. * * Use this operation to either generate or import an existing secret, such as a TLS certificate, that you can manage * in your Secrets Manager service instance. A successful request stores the secret in your dedicated instance, based * on the secret type and data that you specify. The response returns the ID value of the secret, along with other * metadata. * * To learn more about the types of secrets that you can create with Secrets Manager, check out the * [docs](https://cloud.ibm.com/docs/secrets-manager?topic=secrets-manager-what-is-secret). * * @param {Object} params - The parameters to send to the service. * @param {SecretPrototype} params.secretPrototype - * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<SecretsManagerV2.Response<SecretsManagerV2.Secret>>} */ SecretsManagerV2.prototype.createSecret = function (params) { var _params = __assign({}, params); var _requiredParams = ['secretPrototype']; var _validParams = ['secretPrototype', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = _params.secretPrototype; var sdkHeaders = (0, common_1.getSdkHeaders)(SecretsManagerV2.DEFAULT_SERVICE_NAME, 'v2', 'createSecret'); var parameters = { options: { url: '/api/v2/secrets', method: 'POST', body: body, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', 'Content-Type': 'application/json', }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * List secrets. * * List the secrets that are available in your Secrets Manager instance. * * @param {Object} [params] - The parameters to send to the service. * @param {number} [params.offset] - The number of secrets to skip. By specifying `offset`, you retrieve a subset of * items that starts with the `offset` value. Use `offset` with `limit` to page through your available resources. * * **Usage:** If you have 100 secrets in your instance, and you want to retrieve secrets 26 through 50, use * `..?offset=25&limit=25`. * @param {number} [params.limit] - The number of secrets to retrieve. By default, list operations return the first * 200 items. To retrieve a different set of items, use `limit` with `offset` to page through your available * resources. Maximum limit allowed is 1000 secrets. * * **Usage:** If you want to retrieve only the first 25 secrets in your instance, use * `..?limit=25`. * @param {string} [params.sort] - Sort a collection of secrets by the specified field in ascending order. To sort in * descending order use the `-` character * * * **Available values:** id | created_at | updated_at | expiration_date | secret_type | name * * **Usage:** To sort a list of secrets by their creation date, use * `../secrets?sort=created_at`. * @param {string} [params.search] - Obtain a collection of secrets that contain the specified string in one or more * of the fields: `id`, `name`, `description`, * `labels`, `secret_type`. * * **Usage:** If you want to list only the secrets that contain the string `text`, use * `../secrets?search=text`. * @param {string[]} [params.groups] - Filter secrets by groups. * * You can apply multiple filters by using a comma-separated list of secret group IDs. If you need to filter secrets * that are in the default secret group, use the `default` keyword. * * **Usage:** To retrieve a list of secrets that are associated with an existing secret group or the default group, * use `..?groups={secret_group_ID},default`. * @param {string[]} [params.secretTypes] - Filter secrets by types. * * You can apply multiple filters by using a comma-separated list of secret types. * * **Usage:** To retrieve a list of imported certificates and public certificates use * `..?secret_types=imported_cert,public_cert`. * @param {string[]} [params.matchAllLabels] - Filter secrets by labels. * * You can use a comma-separated list of labels to filter secrets that include all of the labels in the list. * * **Usage:** To retrieve a list of secrets that include both the label "dev" and the label "us-south" in their list * of labels, use `..?labels=dev,us-south`. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<SecretsManagerV2.Response<SecretsManagerV2.SecretMetadataPaginatedCollection>>} */ SecretsManagerV2.prototype.listSecrets = function (params) { var _params = __assign({}, params); var _requiredParams = []; var _validParams = ['offset', 'limit', 'sort', 'search', 'groups', 'secretTypes', 'matchAllLabels', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var query = { 'offset': _params.offset, 'limit': _params.limit, 'sort': _params.sort, 'search': _params.search, 'groups': _params.groups, 'secret_types': _params.secretTypes, 'match_all_labels': _params.matchAllLabels, }; var sdkHeaders = (0, common_1.getSdkHeaders)(SecretsManagerV2.DEFAULT_SERVICE_NAME, 'v2', 'listSecrets'); var parameters = { options: { url: '/api/v2/secrets', method: 'GET', qs: query, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Get a secret. * * Get a secret and its details by specifying the ID of the secret. * * A successful request returns the secret data that is associated with your secret, along with other metadata. To * view only the details of a specified secret without retrieving its value, use the Get secret metadata operation. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - The UUID that uniquely identifies your secret. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<SecretsManagerV2.Response<SecretsManagerV2.Secret>>} */ SecretsManagerV2.prototype.getSecret = function (params) { var _params = __assign({}, params); var _requiredParams = ['id']; var _validParams = ['id', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var path = { 'id': _params.id, }; var sdkHeaders = (0, common_1.getSdkHeaders)(SecretsManagerV2.DEFAULT_SERVICE_NAME, 'v2', 'getSecret'); var parameters = { options: { url: '/api/v2/secrets/{id}', method: 'GET', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Delete a secret. * * Delete a secret by specifying the ID of the secret. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - The UUID that uniquely identifies your secret. * @param {boolean} [params.forceDelete] - Set to `true` to force delete the secret. Available only for custom * credentials secret type. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<SecretsManagerV2.Response<SecretsManagerV2.EmptyObject>>} */ SecretsManagerV2.prototype.deleteSecret = function (params) { var _params = __assign({}, params); var _requiredParams = ['id']; var _validParams = ['id', 'forceDelete', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var query = { 'force_delete': _params.forceDelete, }; var path = { 'id': _params.id, }; var sdkHeaders = (0, common_1.getSdkHeaders)(SecretsManagerV2.DEFAULT_SERVICE_NAME, 'v2', 'deleteSecret'); var parameters = { options: { url: '/api/v2/secrets/{id}', method: 'DELETE', qs: query, path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, {}, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Get the metadata of a secret. * * Get the metadata of a secret by specifying the ID of the secret. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - The UUID that uniquely identifies your secret. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<SecretsManagerV2.Response<SecretsManagerV2.SecretMetadata>>} */ SecretsManagerV2.prototype.getSecretMetadata = function (params) { var _params = __assign({}, params); var _requiredParams = ['id']; var _validParams = ['id', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var path = { 'id': _params.id, }; var sdkHeaders = (0, common_1.getSdkHeaders)(SecretsManagerV2.DEFAULT_SERVICE_NAME, 'v2', 'getSecretMetadata'); var parameters = { options: { url: '/api/v2/secrets/{id}/metadata', method: 'GET', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Update the metadata of a secret. * * Update the metadata of a secret, such as its name or description. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - The UUID that uniquely identifies your secret. * @param {SecretMetadataPatch} params.secretMetadataPatch - * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<SecretsManagerV2.Response<SecretsManagerV2.SecretMetadata>>} */ SecretsManagerV2.prototype.updateSecretMetadata = function (params) { var _params = __assign({}, params); var _requiredParams = ['id', 'secretMetadataPatch']; var _validParams = ['id', 'secretMetadataPatch', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = _params.secretMetadataPatch; var path = { 'id': _params.id, }; var sdkHeaders = (0, common_1.getSdkHeaders)(SecretsManagerV2.DEFAULT_SERVICE_NAME, 'v2', 'updateSecretMetadata'); var parameters = { options: { url: '/api/v2/secrets/{id}/metadata', method: 'PATCH', body: body, path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', 'Content-Type': 'application/merge-patch+json', }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Create a secret action. * * Create a secret action. This operation supports the following actions:. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - The UUID that uniquely identifies your secret. * @param {SecretActionPrototype} params.secretActionPrototype - * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<SecretsManagerV2.Response<SecretsManagerV2.SecretAction>>} */ SecretsManagerV2.prototype.createSecretAction = function (params) { var _params = __assign({}, params); var _requiredParams = ['id', 'secretActionPrototype']; var _validParams = ['id', 'secretActionPrototype', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = _params.secretActionPrototype; var path = { 'id': _params.id, }; var sdkHeaders = (0, common_1.getSdkHeaders)(SecretsManagerV2.DEFAULT_SERVICE_NAME, 'v2', 'createSecretAction'); var parameters = { options: { url: '/api/v2/secrets/{id}/actions', method: 'POST', body: body, path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', 'Content-Type': 'application/json', }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Get a secret by name. * * Get a secret and its details by specifying the Name and Type of the secret. * * A successful request returns the secret data that is associated with your secret, along with other metadata. To * view only the details of a specified secret without retrieving its value, use the Get secret metadata operation. * * @param {Object} params - The parameters to send to the service. * @param {string} params.secretType - The secret type. Supported types are arbitrary, imported_cert, public_cert, * private_cert, iam_credentials, service_credentials, kv, and username_password. * @param {string} params.name - A human-readable name to assign to your secret. To protect your privacy, do not use * personal data, such as your name or location, as a name for your secret. * @param {string} params.secretGroupName - The name of your secret group. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<SecretsManagerV2.Response<SecretsManagerV2.Secret>>} */ SecretsManagerV2.prototype.getSecretByNameType = function (params) { var _params = __assign({}, params); var _requiredParams = ['secretType', 'name', 'secretGroupName']; var _validParams = ['secretType', 'name', 'secretGroupName', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var path = { 'secret_type': _params.secretType, 'name': _params.name, 'secret_group_name': _params.secretGroupName, }; var sdkHeaders = (0, common_1.getSdkHeaders)(SecretsManagerV2.DEFAULT_SERVICE_NAME, 'v2', 'getSecretByNameType'); var parameters = { options: { url: '/api/v2/secret_groups/{secret_group_name}/secret_types/{secret_type}/secrets/{name}', method: 'GET', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /************************* * secretVersions ************************/ /** * Create a new secret version. * * Create a new secret version. * * @param {Object} params - The parameters to send to the service. * @param {string} params.secretId - The UUID that uniquely identifies your secret. * @param {SecretVersionPrototype} params.secretVersionPrototype - * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<SecretsManagerV2.Response<SecretsManagerV2.SecretVersion>>} */ SecretsManagerV2.prototype.createSecretVersion = function (params) { var _params = __assign({}, params); var _requiredParams = ['secretId', 'secretVersionPrototype']; var _validParams = ['secretId', 'secretVersionPrototype', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = _params.secretVersionPrototype; var path = { 'secret_id': _params.secretId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(SecretsManagerV2.DEFAULT_SERVICE_NAME, 'v2', 'createSecretVersion'); var parameters = { options: { url: '/api/v2/secrets/{secret_id}/versions', method: 'POST', body: body, path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', 'Content-Type': 'application/json', }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * List versions of a secret. * * List the versions of a secret. * * A successful request returns the list of versions of a secret, along with the metadata of each version. * * @param {Object} params - The parameters to send to the service. * @param {string} params.secretId - The UUID that uniquely identifies your secret. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<SecretsManagerV2.Response<SecretsManagerV2.SecretVersionMetadataCollection>>} */ SecretsManagerV2.prototype.listSecretVersions = function (params) { var _params = __assign({}, params); var _requiredParams = ['secretId']; var _validParams = ['secretId', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var path = { 'secret_id': _params.secretId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(SecretsManagerV2.DEFAULT_SERVICE_NAME, 'v2', 'listSecretVersions'); var parameters = { options: { url: '/api/v2/secrets/{secret_id}/versions', method: 'GET', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Get a version of a secret. * * Get a version of a secret by specifying the ID of the version. You can use the `current` or `previous` aliases to * refer to the current or previous secret version. * * A successful request returns the secret data that is associated with the specified version of your secret, along * with other metadata. * * @param {Object} params - The parameters to send to the service. * @param {string} params.secretId - The UUID that uniquely identifies your secret. * @param {string} params.id - The UUID that uniquely identifies your secret version. You can use the `current` or * `previous` aliases to refer to the current or previous secret version. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<SecretsManagerV2.Response<SecretsManagerV2.SecretVersion>>} */ SecretsManagerV2.prototype.getSecretVersion = function (params) { var _params = __assign({}, params); var _requiredParams = ['secretId', 'id']; var _validParams = ['secretId', 'id', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var path = { 'secret_id': _params.secretId, 'id': _params.id, }; var sdkHeaders = (0, common_1.getSdkHeaders)(SecretsManagerV2.DEFAULT_SERVICE_NAME, 'v2', 'getSecretVersion'); var parameters = { options: { url: '/api/v2/secrets/{secret_id}/versions/{id}', method: 'GET', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Delete the data of a secret version. * * Delete the data of a secret version by specifying its version ID. * * This operation is available for the following secret types: * * `iam_credentials`: current version only * * `custom_credentials`: both current and previous versions. * * @param {Object} params - The parameters to send to the service. * @param {string} params.secretId - The UUID that uniquely identifies your secret. * @param {string} params.id - The UUID that uniquely identifies your secret version. You can use the `current` or * `previous` aliases to refer to the current or previous secret version. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<SecretsManagerV2.Response<SecretsManagerV2.EmptyObject>>} */ SecretsManagerV2.prototype.deleteSecretVersionData = function (params) { var _params = __assign({}, params); var _requiredParams = ['secretId', 'id']; var _validParams = ['secretId', 'id', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var path = { 'secret_id': _params.secretId, 'id': _params.id, }; var sdkHeaders = (0, common_1.getSdkHeaders)(SecretsManagerV2.DEFAULT_SERVICE_NAME, 'v2', 'deleteSecretVersionData'); var parameters = { options: { url: '/api/v2/secrets/{secret_id}/versions/{id}/secret_data', method: 'DELETE', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, {}, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Get the metadata of a secret version. * * Get the metadata of a secret version by specifying the ID of the version. You can use the `current` or `previous` * aliases to refer to the current or previous secret version. * * A successful request returns the metadata that is associated with the specified version of your secret. * * @param {Object} params - The parameters to send to the service. * @param {string} params.secretId - The UUID that uniquely identifies your secret. * @param {string} params.id - The UUID that uniquely identifies your secret version. You can use the `current` or * `previous` aliases to refer to the current or previous secret version. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<SecretsManagerV2.Response<SecretsManagerV2.SecretVersionMetadata>>} */ SecretsManagerV2.prototype.getSecretVersionMetadata = function (params) { var _params = __assign({}, params); var _requiredParams = ['secretId', 'id']; var _validParams = ['secretId', 'id', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var path = { 'secret_id': _params.secretId, 'id': _params.id, }; var sdkHeaders = (0, common_1.getSdkHeaders)(SecretsManagerV2.DEFAULT_SERVICE_NAME, 'v2', 'getSecretVersionMetadata'); var parameters = { options: { url: '/api/v2/secrets/{secret_id}/versions/{id}/metadata', method: 'GET', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Update the metadata of a secret version. * * Update the custom metadata of a secret version. * * @param {Object} params - The parameters to send to the service. * @param {string} params.secretId - The UUID that uniquely identifies your secret. * @param {string} params.id - The UUID that uniquely identifies your secret version. You can use the `current` or * `previous` aliases to refer to the current or previous secret version. * @param {JsonObject} [params.versionCustomMetadata] - The secret version metadata that a user can customize. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<SecretsManagerV2.Response<SecretsManagerV2.SecretVersionMetadata>>} */ SecretsManagerV2.prototype.updateSecretVersionMetadata = function (params) { var _params = __assign({}, params); var _requiredParams = ['secretId', 'id']; var _validParams = ['secretId', 'id', 'versionCustomMetadata', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = { 'version_custom_metadata': _params.versionCustomMetadata, }; var path = { 'secret_id': _params.secretId, 'id': _params.id, }; var sdkHeaders = (0, common_1.getSdkHeaders)(SecretsManagerV2.DEFAULT_SERVICE_NAME, 'v2', 'updateSecretVersionMetadata'); var parameters = { options: { url: '/api/v2/secrets/{secret_id}/versions/{id}/metadata', method: 'PATCH', body: body, path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', 'Content-Type': 'application/merge-patch+json', }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Create a version action. * * Create a secret version action. This operation supports the following actions: * * - `private_cert_action_revoke_certificate`: Revoke a version of a private certificate. * * @param {Object} params - The parameters to send to the service. * @param {string} params.secretId - The UUID that uniquely identifies your secret. * @param {string} params.id - The UUID that uniquely identifies your secret version. You can use the `current` or * `previous` aliases to refer to the current or previous secret version. * @param {SecretVersionActionPrototype} params.secretVersionActionPrototype - * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<SecretsManagerV2.Response<SecretsManagerV2.VersionAction>>} */ SecretsManagerV2.prototype.createSecretVersionAction = function (params) { var _params = __assign({}, params); var _requiredParams = ['secretId', 'id', 'secretVersionActionPrototype']; var _validParams = ['secretId', 'id', 'secretVersionActionPrototype', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = _params.secretVersionActionPrototype; var path = { 'secret_id': _params.secretId, 'id': _params.id, }; var sdkHeaders = (0, common_1.getSdkHeaders)(SecretsManagerV2.DEFAULT_SERVICE_NAME, 'v2', 'createSecretVer