UNPKG

@ibm-cloud/platform-services

Version:

Node.js client library for IBM Cloud Platform Services

1,073 lines 250 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); }; /** * IBM OpenAPI SDK Code Generator Version: 3.107.1-41b0fbd0-20250825-080732 */ var extend = require("extend"); var ibm_cloud_sdk_core_1 = require("ibm-cloud-sdk-core"); var common_1 = require("../lib/common"); /** * The IAM Identity Service API allows for the management of Account Settings and Identities (Service IDs, ApiKeys). * * API Version: 1.0.0 */ var IamIdentityV1 = /** @class */ (function (_super) { __extends(IamIdentityV1, _super); /** * Construct a IamIdentityV1 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 {IamIdentityV1} */ function IamIdentityV1(options) { var _this = this; options = options || {}; _this = _super.call(this, options) || this; if (options.serviceUrl) { _this.setServiceUrl(options.serviceUrl); } else { _this.setServiceUrl(IamIdentityV1.DEFAULT_SERVICE_URL); } return _this; } /************************* * Factory method ************************/ /** * Constructs an instance of IamIdentityV1 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 {IamIdentityV1} */ IamIdentityV1.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 IamIdentityV1(options); service.configureService(options.serviceName); if (options.serviceUrl) { service.setServiceUrl(options.serviceUrl); } return service; }; /************************* * serviceIDs ************************/ /** * List service IDs. * * Returns a list of service IDs. Users can manage user API keys for themself, or service ID API keys for service IDs * they have access to. Note: apikey details are only included in the response when creating a Service ID with an api * key. * * @param {Object} [params] - The parameters to send to the service. * @param {string} [params.accountId] - Account ID of the service ID(s) to query. This parameter is required (unless * using a pagetoken). * @param {string} [params.groupId] - Group ID of the service ID(s) to query. If this parameter is not provided the * default group is applied. * @param {string} [params.name] - Name of the service ID(s) to query. Optional.20 items per page. Valid range is 1 to * 100. * @param {number} [params.pagesize] - Optional size of a single page. Default is 20 items per page. Valid range is 1 * to 100. * @param {string} [params.pagetoken] - Optional Prev or Next page token returned from a previous query execution. * Default is start with first page. * @param {string} [params.sort] - Optional sort property, valid values are name, description, created_at and * modified_at. If specified, the items are sorted by the value of this property. * @param {string} [params.order] - Optional sort order, valid values are asc and desc. Default: asc. * @param {boolean} [params.includeHistory] - Defines if the entity history is included in the response. * @param {string} [params.filter] - An optional filter query parameter used to refine the results of the search * operation. For more information see [Filtering list results](#filter-list-results) section. * @param {string} [params.showGroupId] - Defines if the service ID group ID is included in the response. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<IamIdentityV1.Response<IamIdentityV1.ServiceIdList>>} */ IamIdentityV1.prototype.listServiceIds = function (params) { var _params = __assign({}, params); var _requiredParams = []; var _validParams = [ 'accountId', 'groupId', 'name', 'pagesize', 'pagetoken', 'sort', 'order', 'includeHistory', 'filter', 'showGroupId', 'signal', 'headers', ]; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var query = { 'account_id': _params.accountId, 'group_id': _params.groupId, 'name': _params.name, 'pagesize': _params.pagesize, 'pagetoken': _params.pagetoken, 'sort': _params.sort, 'order': _params.order, 'include_history': _params.includeHistory, 'filter': _params.filter, 'show_group_id': _params.showGroupId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'listServiceIds'); var parameters = { options: { url: '/v1/serviceids/', 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); }; /** * Create a service ID. * * Creates a service ID for an IBM Cloud account. Users can manage user API keys for themself, or service ID API keys * for service IDs they have access to. * * @param {Object} params - The parameters to send to the service. * @param {string} params.accountId - ID of the account the service ID belongs to. * @param {string} params.name - Name of the Service Id. The name is not checked for uniqueness. Therefore multiple * names with the same value can exist. Access is done via the UUID of the Service Id. * @param {string} [params.groupId] - ID of the group to which the service ID belongs to. If the value is not set, the * service ID is bound to the default group. * @param {string} [params.description] - The optional description of the Service Id. The 'description' property is * only available if a description was provided during a create of a Service Id. * @param {string[]} [params.uniqueInstanceCrns] - Optional list of CRNs (string array) which point to the services * connected to the service ID. * @param {ApiKeyInsideCreateServiceIdRequest} [params.apikey] - Parameters for the API key in the Create service Id * V1 REST request. * @param {string} [params.showGroupId] - Defines if the service ID group ID is included in the response. * @param {string} [params.entityLock] - Indicates if the service ID is locked for further write operations. False by * default. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<IamIdentityV1.Response<IamIdentityV1.ServiceId>>} */ IamIdentityV1.prototype.createServiceId = function (params) { var _params = __assign({}, params); var _requiredParams = ['accountId', 'name']; var _validParams = [ 'accountId', 'name', 'groupId', 'description', 'uniqueInstanceCrns', 'apikey', 'showGroupId', 'entityLock', 'signal', 'headers', ]; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = { 'account_id': _params.accountId, 'name': _params.name, 'group_id': _params.groupId, 'description': _params.description, 'unique_instance_crns': _params.uniqueInstanceCrns, 'apikey': _params.apikey, }; var query = { 'show_group_id': _params.showGroupId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'createServiceId'); var parameters = { options: { url: '/v1/serviceids/', method: 'POST', body: body, qs: query, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Entity-Lock': _params.entityLock, }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Get details of a service ID. * * Returns the details of a service ID. Users can manage user API keys for themself, or service ID API keys for * service IDs they have access to. Note: apikey details are only included in the response when creating a Service ID * with an api key. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - Unique ID of the service ID. * @param {boolean} [params.includeHistory] - Defines if the entity history is included in the response. * @param {boolean} [params.includeActivity] - Defines if the entity's activity is included in the response. * Retrieving activity data is an expensive operation, so only request this when needed. * @param {string} [params.showGroupId] - Defines if the service ID group ID is included in the response. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<IamIdentityV1.Response<IamIdentityV1.ServiceId>>} */ IamIdentityV1.prototype.getServiceId = function (params) { var _params = __assign({}, params); var _requiredParams = ['id']; var _validParams = [ 'id', 'includeHistory', 'includeActivity', 'showGroupId', 'signal', 'headers', ]; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var query = { 'include_history': _params.includeHistory, 'include_activity': _params.includeActivity, 'show_group_id': _params.showGroupId, }; var path = { 'id': _params.id, }; var sdkHeaders = (0, common_1.getSdkHeaders)(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'getServiceId'); var parameters = { options: { url: '/v1/serviceids/{id}', method: 'GET', qs: query, 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 service ID. * * Updates properties of a service ID. This does NOT affect existing access tokens. Their token content will stay * unchanged until the access token is refreshed. To update a service ID, pass the property to be modified. To delete * one property's value, pass the property with an empty value "".Users can manage user API keys for themself, or * service ID API keys for service IDs they have access to. Note: apikey details are only included in the response * when creating a Service ID with an apikey. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - Unique ID of the service ID to be updated. * @param {string} params.ifMatch - Version of the service ID to be updated. Specify the version that you retrieved as * entity_tag (ETag header) when reading the service ID. This value helps identifying parallel usage of this API. Pass * * to indicate to update any version available. This might result in stale updates. * @param {string} [params.name] - The name of the service ID to update. If specified in the request the parameter * must not be empty. The name is not checked for uniqueness. Failure to this will result in an Error condition. * @param {string} [params.description] - The description of the service ID to update. If specified an empty * description will clear the description of the service ID. If an non empty value is provided the service ID will be * updated. * @param {string[]} [params.uniqueInstanceCrns] - List of CRNs which point to the services connected to this service * ID. If specified an empty list will clear all existing unique instance crns of the service ID. * @param {string} [params.showGroupId] - Defines if the service ID group ID is included in the response. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<IamIdentityV1.Response<IamIdentityV1.ServiceId>>} */ IamIdentityV1.prototype.updateServiceId = function (params) { var _params = __assign({}, params); var _requiredParams = ['id', 'ifMatch']; var _validParams = [ 'id', 'ifMatch', 'name', 'description', 'uniqueInstanceCrns', 'showGroupId', '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, 'unique_instance_crns': _params.uniqueInstanceCrns, }; var query = { 'show_group_id': _params.showGroupId, }; var path = { 'id': _params.id, }; var sdkHeaders = (0, common_1.getSdkHeaders)(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'updateServiceId'); var parameters = { options: { url: '/v1/serviceids/{id}', method: 'PUT', body: body, qs: query, path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', 'Content-Type': 'application/json', 'If-Match': _params.ifMatch, }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Deletes a service ID and associated API keys. * * Deletes a service ID and all API keys associated to it. Before deleting the service ID, all associated API keys are * deleted. In case a Delete Conflict (status code 409) a retry of the request may help as the service ID is only * deleted if the associated API keys were successfully deleted before. Users can manage user API keys for themself, * or service ID API keys for service IDs they have access to. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - Unique ID of the service ID. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<IamIdentityV1.Response<IamIdentityV1.EmptyObject>>} */ IamIdentityV1.prototype.deleteServiceId = 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)(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'deleteServiceId'); var parameters = { options: { url: '/v1/serviceids/{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); }; /** * Lock the service ID. * * Locks a service ID by ID. Users can manage user API keys for themself, or service ID API keys for service IDs they * have access to. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - Unique ID of the service ID. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<IamIdentityV1.Response<IamIdentityV1.EmptyObject>>} */ IamIdentityV1.prototype.lockServiceId = 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)(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'lockServiceId'); var parameters = { options: { url: '/v1/serviceids/{id}/lock', method: 'POST', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, {}, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Unlock the service ID. * * Unlocks a service ID by ID. Users can manage user API keys for themself, or service ID API keys for service IDs * they have access to. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - Unique ID of the service ID. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<IamIdentityV1.Response<IamIdentityV1.EmptyObject>>} */ IamIdentityV1.prototype.unlockServiceId = 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)(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'unlockServiceId'); var parameters = { options: { url: '/v1/serviceids/{id}/lock', 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); }; /************************* * serviceIDGroups ************************/ /** * List service ID groups. * * Returns a list of all service ID groups for the given account ID. * * @param {Object} [params] - The parameters to send to the service. * @param {string} [params.accountId] - Account ID of the service ID groups to query. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<IamIdentityV1.Response<IamIdentityV1.ServiceIdGroupList>>} */ IamIdentityV1.prototype.listServiceIdGroup = function (params) { var _params = __assign({}, params); var _requiredParams = []; var _validParams = ['accountId', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var query = { 'account_id': _params.accountId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'listServiceIdGroup'); var parameters = { options: { url: '/v1/serviceid_groups', 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); }; /** * Create a service ID group. * * Creates a service ID group for the given account ID. * * @param {Object} params - The parameters to send to the service. * @param {string} params.accountId - ID of the account the service ID group belongs to. * @param {string} params.name - Name of the service ID group. Unique in the account. * @param {string} [params.description] - Description of the service ID group. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<IamIdentityV1.Response<IamIdentityV1.ServiceIdGroup>>} */ IamIdentityV1.prototype.createServiceIdGroup = function (params) { var _params = __assign({}, params); var _requiredParams = ['accountId', 'name']; var _validParams = ['accountId', 'name', 'description', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = { 'account_id': _params.accountId, 'name': _params.name, 'description': _params.description, }; var sdkHeaders = (0, common_1.getSdkHeaders)(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'createServiceIdGroup'); var parameters = { options: { url: '/v1/serviceid_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); }; /** * Get details of a service ID group. * * Returns the details of a service ID group. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - Unique ID of the service ID group. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<IamIdentityV1.Response<IamIdentityV1.ServiceIdGroup>>} */ IamIdentityV1.prototype.getServiceIdGroup = 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)(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'getServiceIdGroup'); var parameters = { options: { url: '/v1/serviceid_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 service ID group. * * Update a service ID group. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - Unique ID of the service ID group to be updated. * @param {string} params.ifMatch - Version of the service ID gorup to be updated. Specify the version that you * retrieved when reading service ID group. This value helps identifying parallel usage of this API. Pass * to * indicate to update any version available. This might result in stale updates. * @param {string} params.name - Name of the service ID group. Unique in the account. * @param {string} [params.description] - Description of the service ID group. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<IamIdentityV1.Response<IamIdentityV1.ServiceIdGroup>>} */ IamIdentityV1.prototype.updateServiceIdGroup = function (params) { var _params = __assign({}, params); var _requiredParams = ['id', 'ifMatch', 'name']; var _validParams = ['id', 'ifMatch', '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)(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'updateServiceIdGroup'); var parameters = { options: { url: '/v1/serviceid_groups/{id}', method: 'PUT', body: body, path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', 'Content-Type': 'application/json', 'If-Match': _params.ifMatch, }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Delete a service ID group. * * Delete a service ID group. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - Unique ID of the service ID group. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<IamIdentityV1.Response<IamIdentityV1.EmptyObject>>} */ IamIdentityV1.prototype.deleteServiceIdGroup = 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)(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'deleteServiceIdGroup'); var parameters = { options: { url: '/v1/serviceid_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); }; /************************* * aPIKeys ************************/ /** * Get API keys for a given service or user IAM ID and account ID. * * Returns the list of API key details for a given service or user IAM ID and account ID. Users can manage user API * keys for themself, or service ID API keys for service IDs they have access to. * * @param {Object} [params] - The parameters to send to the service. * @param {string} [params.accountId] - Account ID of the API keys to query. If a service IAM ID is specified in * iam_id then account_id must match the account of the IAM ID. If a user IAM ID is specified in iam_id then then * account_id must match the account of the Authorization token. * @param {string} [params.iamId] - IAM ID of the API keys to be queried. The IAM ID may be that of a user or a * service. For a user IAM ID iam_id must match the Authorization token. * @param {number} [params.pagesize] - Optional size of a single page. Default is 20 items per page. Valid range is 1 * to 100. * @param {string} [params.pagetoken] - Optional Prev or Next page token returned from a previous query execution. * Default is start with first page. * @param {string} [params.scope] - Optional parameter to define the scope of the queried API keys. Can be 'entity' * (default) or 'account'. * @param {string} [params.type] - Optional parameter to filter the type of the queried API keys. Can be 'user' or * 'serviceid'. * @param {string} [params.sort] - Optional sort property, valid values are name, description, created_at and * created_by. If specified, the items are sorted by the value of this property. * @param {string} [params.order] - Optional sort order, valid values are asc and desc. Default: asc. * @param {boolean} [params.includeHistory] - Defines if the entity history is included in the response. * @param {string} [params.filter] - An optional filter query parameter used to refine the results of the search * operation. For more information see [Filtering list results](#filter-list-results) section. * @param {string} [params.groupId] - Optional group ID of the service ID(s) to which the searched API keys are bound. * If this parameter is not provided the default group is applied on service ID API keys. For user API keys this * parameter is ignored as they always belong to the default group. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<IamIdentityV1.Response<IamIdentityV1.ApiKeyList>>} */ IamIdentityV1.prototype.listApiKeys = function (params) { var _params = __assign({}, params); var _requiredParams = []; var _validParams = [ 'accountId', 'iamId', 'pagesize', 'pagetoken', 'scope', 'type', 'sort', 'order', 'includeHistory', 'filter', 'groupId', 'signal', 'headers', ]; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var query = { 'account_id': _params.accountId, 'iam_id': _params.iamId, 'pagesize': _params.pagesize, 'pagetoken': _params.pagetoken, 'scope': _params.scope, 'type': _params.type, 'sort': _params.sort, 'order': _params.order, 'include_history': _params.includeHistory, 'filter': _params.filter, 'group_id': _params.groupId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'listApiKeys'); var parameters = { options: { url: '/v1/apikeys', 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); }; /** * Create an API key. * * Creates an API key for a UserID or service ID. Users can manage user API keys for themself, or service ID API keys * for service IDs they have access to. * * @param {Object} params - The parameters to send to the service. * @param {string} params.name - Name of the API key. The name is not checked for uniqueness. Therefore multiple names * with the same value can exist. Access is done via the UUID of the API key. * @param {string} params.iamId - The iam_id that this API key authenticates. * @param {string} [params.description] - The optional description of the API key. The 'description' property is only * available if a description was provided during a create of an API key. * @param {string} [params.accountId] - The account ID of the API key. * @param {string} [params.apikey] - You can optionally passthrough the API key value for this API key. If passed, a * minimum length validation of 32 characters for that apiKey value is done, i.e. the value can contain any characters * and can even be non-URL safe, but the minimum length requirement must be met. If omitted, the API key management * will create an URL safe opaque API key value. The value of the API key is checked for uniqueness. Ensure enough * variations when passing in this value. * @param {boolean} [params.storeValue] - Send true or false to set whether the API key value is retrievable in the * future by using the Get details of an API key request. If you create an API key for a user, you must specify * `false` or omit the value. We don't allow storing of API keys for users. * @param {boolean} [params.supportSessions] - Defines whether you can manage CLI login sessions for the API key. When * `true`, sessions are created and can be reviewed or revoked. When `false`, no sessions are tracked. To block * access, delete or rotate the API key. Available only for user API keys. * @param {string} [params.actionWhenLeaked] - Defines the action to take when API key is leaked, valid values are * 'none', 'disable' and 'delete'. * @param {string} [params.entityLock] - Indicates if the API key is locked for further write operations. False by * default. * @param {string} [params.entityDisable] - Indicates if the API key is disabled. False by default. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<IamIdentityV1.Response<IamIdentityV1.ApiKey>>} */ IamIdentityV1.prototype.createApiKey = function (params) { var _params = __assign({}, params); var _requiredParams = ['name', 'iamId']; var _validParams = [ 'name', 'iamId', 'description', 'accountId', 'apikey', 'storeValue', 'supportSessions', 'actionWhenLeaked', 'entityLock', 'entityDisable', '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, 'iam_id': _params.iamId, 'description': _params.description, 'account_id': _params.accountId, 'apikey': _params.apikey, 'store_value': _params.storeValue, 'support_sessions': _params.supportSessions, 'action_when_leaked': _params.actionWhenLeaked, }; var sdkHeaders = (0, common_1.getSdkHeaders)(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'createApiKey'); var parameters = { options: { url: '/v1/apikeys', method: 'POST', body: body, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Entity-Lock': _params.entityLock, 'Entity-Disable': _params.entityDisable, }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Get details of an API key by its value. * * Returns the details of an API key by its value. Users can manage user API keys for themself, or service ID API keys * for service IDs they have access to. * * @param {Object} [params] - The parameters to send to the service. * @param {string} [params.iamApiKey] - API key value. * @param {boolean} [params.includeHistory] - Defines if the entity history is included in the response. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<IamIdentityV1.Response<IamIdentityV1.ApiKey>>} */ IamIdentityV1.prototype.getApiKeysDetails = function (params) { var _params = __assign({}, params); var _requiredParams = []; var _validParams = ['iamApiKey', 'includeHistory', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var query = { 'include_history': _params.includeHistory, }; var sdkHeaders = (0, common_1.getSdkHeaders)(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'getApiKeysDetails'); var parameters = { options: { url: '/v1/apikeys/details', method: 'GET', qs: query, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', 'IAM-ApiKey': _params.iamApiKey, }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Get details of an API key. * * Returns the details of an API key. Users can manage user API keys for themself, or service ID API keys for service * IDs they have access to. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - Unique ID of the API key. * @param {boolean} [params.includeHistory] - Defines if the entity history is included in the response. * @param {boolean} [params.includeActivity] - Defines if the entity's activity is included in the response. * Retrieving activity data is an expensive operation, so only request this when needed. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<IamIdentityV1.Response<IamIdentityV1.ApiKey>>} */ IamIdentityV1.prototype.getApiKey = function (params) { var _params = __assign({}, params); var _requiredParams = ['id']; var _validParams = ['id', 'includeHistory', 'includeActivity', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var query = { 'include_history': _params.includeHistory, 'include_activity': _params.includeActivity, }; var path = { 'id': _params.id, }; var sdkHeaders = (0, common_1.getSdkHeaders)(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'getApiKey'); var parameters = { options: { url: '/v1/apikeys/{id}', method: 'GET', qs: query, 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); }; /** * Updates an API key. * * Updates properties of an API key. This does NOT affect existing access tokens. Their token content will stay * unchanged until the access token is refreshed. To update an API key, pass the property to be modified. To delete * one property's value, pass the property with an empty value "". Users can manage user API keys for themself, or * service ID API keys for service IDs they have access to. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - Unique ID of the API key to be updated. * @param {string} params.ifMatch - Version of the API key to be updated. Specify the version that you retrieved when * reading the API key. This value helps identifying parallel usage of this API. Pass * to indicate to update any * version available. This might result in stale updates. * @param {string} [params.name] - The name of the API key to update. If specified in the request the parameter must * not be empty. The name is not checked for uniqueness. Failure to this will result in an Error condition. * @param {string} [params.description] - The description of the API key to update. If specified an empty description * will clear the description of the API key. If a non empty value is provided the API key will be updated. * @param {boolean} [params.supportSessions] - Defines whether you can manage CLI login sessions for the API key. When * `true`, sessions are created and can be reviewed or revoked. When `false`, no sessions are tracked. To block * access, delete or rotate the API key. Available only for user API keys. * @param {string} [params.actionWhenLeaked] - Defines the action to take when API key is leaked, valid values are * 'none', 'disable' and 'delete'. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<IamIdentityV1.Response<IamIdentityV1.ApiKey>>} */ IamIdentityV1.prototype.updateApiKey = function (params) { var _params = __assign({}, params); var _requiredParams = ['id', 'ifMatch']; var _validParams = [ 'id', 'ifMatch', 'name', 'description', 'supportSessions', 'actionWhenLeaked', '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, 'support_sessions': _params.supportSessions, 'action_when_leaked': _params.actionWhenLeaked, }; var path = { 'id': _params.id, }; var sdkHeaders = (0, common_1.getSdkHeaders)(IamIdentityV1.DEFAULT_SERVICE_NAME, 'v1', 'updateApiKey'); var parameters = { options: { url: '/v1/apikeys/{id}', method: 'PUT', body: body, path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', 'Content-Type': 'application/json', 'If-Match': _params.ifMatch, }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Deletes an API key. * * Deletes an API key. Existing tokens will remain valid until expired. Users can manage user API keys for themself, * or service ID API keys for service IDs they have access to. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - Unique ID of the API key. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<IamIdentityV1.Response<IamIdentityV1.EmptyObject>>} */ IamIdentityV1.prototype.deleteApiKey = function (params) { var _params = __assign({}, params); var _requiredParams = ['id']; var _validParams = ['id', 'signal', 'headers']; var _validationError