UNPKG

@ibm-cloud/platform-services

Version:

Node.js client library for IBM Cloud Platform Services

1,042 lines (1,041 loc) 104 kB
"use strict"; /** * (C) Copyright IBM Corp. 2024. * * 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.94.1-71478489-20240820-161623 */ /* 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"); /** * Manage lifecycle of your Cloud resources using Resource Controller APIs. Resources are provisioned globally in an * account scope. Supports asynchronous provisioning of resources. Enables consumption of a global resource through a * Cloud Foundry space in any region. * * API Version: 2.0 */ var ResourceControllerV2 = /** @class */ (function (_super) { __extends(ResourceControllerV2, _super); /** * Construct a ResourceControllerV2 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 {ResourceControllerV2} */ function ResourceControllerV2(options) { var _this = this; options = options || {}; _this = _super.call(this, options) || this; if (options.serviceUrl) { _this.setServiceUrl(options.serviceUrl); } else { _this.setServiceUrl(ResourceControllerV2.DEFAULT_SERVICE_URL); } return _this; } /************************* * Factory method ************************/ /** * Constructs an instance of ResourceControllerV2 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 {ResourceControllerV2} */ ResourceControllerV2.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 ResourceControllerV2(options); service.configureService(options.serviceName); if (options.serviceUrl) { service.setServiceUrl(options.serviceUrl); } return service; }; /************************* * resourceInstances ************************/ /** * Get a list of all resource instances. * * View a list of all available resource instances. Resources is a broad term that could mean anything from a service * instance to a virtual machine associated with the customer account. * * @param {Object} [params] - The parameters to send to the service. * @param {string} [params.guid] - The GUID of the instance. * @param {string} [params.name] - The human-readable name of the instance. * @param {string} [params.resourceGroupId] - The ID of the resource group. * @param {string} [params.resourceId] - The unique ID of the offering. This value is provided by and stored in the * global catalog. * @param {string} [params.resourcePlanId] - The unique ID of the plan associated with the offering. This value is * provided by and stored in the global catalog. * @param {string} [params.type] - The type of the instance, for example, `service_instance`. * @param {string} [params.subType] - The sub-type of instance, for example, `kms`. * @param {number} [params.limit] - Limit on how many items should be returned. * @param {string} [params.start] - An optional token that indicates the beginning of the page of results to be * returned. Any additional query parameters are ignored if a page token is present. If omitted, the first page of * results is returned. This value is obtained from the 'start' query parameter in the 'next_url' field of the * operation response. * @param {string} [params.state] - The state of the instance. If not specified, instances in state `active` and * `provisioning` are returned. * @param {string} [params.updatedFrom] - Start date inclusive filter. * @param {string} [params.updatedTo] - End date inclusive filter. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ResourceControllerV2.Response<ResourceControllerV2.ResourceInstancesList>>} */ ResourceControllerV2.prototype.listResourceInstances = function (params) { var _params = __assign({}, params); var _requiredParams = []; var _validParams = [ 'guid', 'name', 'resourceGroupId', 'resourceId', 'resourcePlanId', 'type', 'subType', 'limit', 'start', 'state', 'updatedFrom', 'updatedTo', 'headers', ]; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var query = { 'guid': _params.guid, 'name': _params.name, 'resource_group_id': _params.resourceGroupId, 'resource_id': _params.resourceId, 'resource_plan_id': _params.resourcePlanId, 'type': _params.type, 'sub_type': _params.subType, 'limit': _params.limit, 'start': _params.start, 'state': _params.state, 'updated_from': _params.updatedFrom, 'updated_to': _params.updatedTo, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ResourceControllerV2.DEFAULT_SERVICE_NAME, 'v2', 'listResourceInstances'); var parameters = { options: { url: '/v2/resource_instances', method: 'GET', qs: query, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', }, _params.headers), }), }; return this.createRequest(parameters); }; /** * Create (provision) a new resource instance. * * When you provision a service you get an instance of that service. An instance represents the resource with which * you create, and additionally, represents a chargeable record of which billing can occur. * * @param {Object} params - The parameters to send to the service. * @param {string} params.name - The name of the instance. Must be 180 characters or less and cannot include any * special characters other than `(space) - . _ :`. * @param {string} params.target - The deployment location where the instance should be hosted. * @param {string} params.resourceGroup - The ID of the resource group. * @param {string} params.resourcePlanId - The unique ID of the plan associated with the offering. This value is * provided by and stored in the global catalog. * @param {string[]} [params.tags] - Tags that are attached to the instance after provisioning. These tags can be * searched and managed through the Tagging API in IBM Cloud. * @param {boolean} [params.allowCleanup] - A boolean that dictates if the resource instance should be deleted * (cleaned up) during the processing of a region instance delete call. * @param {JsonObject} [params.parameters] - Configuration options represented as key-value pairs that are passed * through to the target resource brokers. Set the `onetime_credentials` property to specify whether newly created * resource key credentials can be retrieved by using get resource key or get a list of all of the resource keys * requests. * @param {boolean} [params.entityLock] - Indicates if the resource instance is locked for further update or delete * operations. It does not affect actions performed on child resources like aliases, bindings or keys. False by * default. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ResourceControllerV2.Response<ResourceControllerV2.ResourceInstance>>} */ ResourceControllerV2.prototype.createResourceInstance = function (params) { var _params = __assign({}, params); var _requiredParams = ['name', 'target', 'resourceGroup', 'resourcePlanId']; var _validParams = [ 'name', 'target', 'resourceGroup', 'resourcePlanId', 'tags', 'allowCleanup', 'parameters', 'entityLock', 'headers', ]; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = { 'name': _params.name, 'target': _params.target, 'resource_group': _params.resourceGroup, 'resource_plan_id': _params.resourcePlanId, 'tags': _params.tags, 'allow_cleanup': _params.allowCleanup, 'parameters': _params.parameters, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ResourceControllerV2.DEFAULT_SERVICE_NAME, 'v2', 'createResourceInstance'); var parameters = { options: { url: '/v2/resource_instances', method: 'POST', body: body, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Entity-Lock': _params.entityLock, }, _params.headers), }), }; return this.createRequest(parameters); }; /** * Get a resource instance. * * Retrieve a resource instance by URL-encoded CRN or GUID. Find more details on a particular instance, like when it * was provisioned and who provisioned it. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - The resource instance URL-encoded CRN or GUID. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ResourceControllerV2.Response<ResourceControllerV2.ResourceInstance>>} */ ResourceControllerV2.prototype.getResourceInstance = function (params) { var _params = __assign({}, params); var _requiredParams = ['id']; var _validParams = ['id', '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)(ResourceControllerV2.DEFAULT_SERVICE_NAME, 'v2', 'getResourceInstance'); var parameters = { options: { url: '/v2/resource_instances/{id}', method: 'GET', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', }, _params.headers), }), }; return this.createRequest(parameters); }; /** * Delete a resource instance. * * Delete a resource instance by URL-encoded CRN or GUID. If the resource instance has any resource keys or aliases * associated with it, use the `recursive=true` parameter to delete it. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - The resource instance URL-encoded CRN or GUID. * @param {boolean} [params.recursive] - Will delete resource bindings, keys and aliases associated with the instance. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ResourceControllerV2.Response<ResourceControllerV2.EmptyObject>>} */ ResourceControllerV2.prototype.deleteResourceInstance = function (params) { var _params = __assign({}, params); var _requiredParams = ['id']; var _validParams = ['id', 'recursive', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var query = { 'recursive': _params.recursive, }; var path = { 'id': _params.id, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ResourceControllerV2.DEFAULT_SERVICE_NAME, 'v2', 'deleteResourceInstance'); var parameters = { options: { url: '/v2/resource_instances/{id}', method: 'DELETE', qs: query, path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, {}, _params.headers), }), }; return this.createRequest(parameters); }; /** * Update a resource instance. * * Use the resource instance URL-encoded CRN or GUID to make updates to the resource instance, like changing the name * or plan. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - The resource instance URL-encoded CRN or GUID. * @param {string} [params.name] - The new name of the instance. Must be 180 characters or less and cannot include any * special characters other than `(space) - . _ :`. * @param {JsonObject} [params.parameters] - The new configuration options for the instance. Set the * `onetime_credentials` property to specify whether newly created resource key credentials can be retrieved by using * get resource key or get a list of all of the resource keys requests. * @param {string} [params.resourcePlanId] - The unique ID of the plan associated with the offering. This value is * provided by and stored in the global catalog. * @param {boolean} [params.allowCleanup] - A boolean that dictates if the resource instance should be deleted * (cleaned up) during the processing of a region instance delete call. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ResourceControllerV2.Response<ResourceControllerV2.ResourceInstance>>} */ ResourceControllerV2.prototype.updateResourceInstance = function (params) { var _params = __assign({}, params); var _requiredParams = ['id']; var _validParams = ['id', 'name', 'parameters', 'resourcePlanId', 'allowCleanup', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = { 'name': _params.name, 'parameters': _params.parameters, 'resource_plan_id': _params.resourcePlanId, 'allow_cleanup': _params.allowCleanup, }; var path = { 'id': _params.id, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ResourceControllerV2.DEFAULT_SERVICE_NAME, 'v2', 'updateResourceInstance'); var parameters = { options: { url: '/v2/resource_instances/{id}', method: 'PATCH', body: body, path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', 'Content-Type': 'application/json', }, _params.headers), }), }; return this.createRequest(parameters); }; /** * Get a list of all resource aliases for the instance. * * Retrieving a list of all resource aliases can help you find out who's using the resource instance. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - The resource instance URL-encoded CRN or GUID. * @param {number} [params.limit] - Limit on how many items should be returned. * @param {string} [params.start] - An optional token that indicates the beginning of the page of results to be * returned. Any additional query parameters are ignored if a page token is present. If omitted, the first page of * results is returned. This value is obtained from the 'start' query parameter in the 'next_url' field of the * operation response. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ResourceControllerV2.Response<ResourceControllerV2.ResourceAliasesList>>} * @deprecated this method is deprecated and may be removed in a future release */ ResourceControllerV2.prototype.listResourceAliasesForInstance = function (params) { ResourceControllerV2._logger.warn('A deprecated operation has been invoked: listResourceAliasesForInstance'); var _params = __assign({}, params); var _requiredParams = ['id']; var _validParams = ['id', 'limit', 'start', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var query = { 'limit': _params.limit, 'start': _params.start, }; var path = { 'id': _params.id, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ResourceControllerV2.DEFAULT_SERVICE_NAME, 'v2', 'listResourceAliasesForInstance'); var parameters = { options: { url: '/v2/resource_instances/{id}/resource_aliases', method: 'GET', qs: query, path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', }, _params.headers), }), }; return this.createRequest(parameters); }; /** * Get a list of all the resource keys for the instance. * * You may have many resource keys for one resource instance. For example, you may have a different resource key for * each user or each role. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - The resource instance URL-encoded CRN or GUID. * @param {number} [params.limit] - Limit on how many items should be returned. * @param {string} [params.start] - An optional token that indicates the beginning of the page of results to be * returned. Any additional query parameters are ignored if a page token is present. If omitted, the first page of * results is returned. This value is obtained from the 'start' query parameter in the 'next_url' field of the * operation response. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ResourceControllerV2.Response<ResourceControllerV2.ResourceKeysList>>} */ ResourceControllerV2.prototype.listResourceKeysForInstance = function (params) { var _params = __assign({}, params); var _requiredParams = ['id']; var _validParams = ['id', 'limit', 'start', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var query = { 'limit': _params.limit, 'start': _params.start, }; var path = { 'id': _params.id, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ResourceControllerV2.DEFAULT_SERVICE_NAME, 'v2', 'listResourceKeysForInstance'); var parameters = { options: { url: '/v2/resource_instances/{id}/resource_keys', method: 'GET', qs: query, path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', }, _params.headers), }), }; return this.createRequest(parameters); }; /** * Lock a resource instance. * * Locks a resource instance. A locked instance can not be updated or deleted. It does not affect actions performed on * child resources like aliases, bindings, or keys. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - The resource instance URL-encoded CRN or GUID. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ResourceControllerV2.Response<ResourceControllerV2.ResourceInstance>>} */ ResourceControllerV2.prototype.lockResourceInstance = function (params) { var _params = __assign({}, params); var _requiredParams = ['id']; var _validParams = ['id', '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)(ResourceControllerV2.DEFAULT_SERVICE_NAME, 'v2', 'lockResourceInstance'); var parameters = { options: { url: '/v2/resource_instances/{id}/lock', method: 'POST', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', }, _params.headers), }), }; return this.createRequest(parameters); }; /** * Unlock a resource instance. * * Unlock a resource instance to update or delete it. Unlocking a resource instance does not affect child resources * like aliases, bindings or keys. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - The resource instance URL-encoded CRN or GUID. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ResourceControllerV2.Response<ResourceControllerV2.ResourceInstance>>} */ ResourceControllerV2.prototype.unlockResourceInstance = function (params) { var _params = __assign({}, params); var _requiredParams = ['id']; var _validParams = ['id', '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)(ResourceControllerV2.DEFAULT_SERVICE_NAME, 'v2', 'unlockResourceInstance'); var parameters = { options: { url: '/v2/resource_instances/{id}/lock', method: 'DELETE', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', }, _params.headers), }), }; return this.createRequest(parameters); }; /** * Cancel the in progress last operation of the resource instance. * * Cancel the in progress last operation of the resource instance. After successful cancellation, the resource * instance is removed. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - The resource instance URL-encoded CRN or GUID. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ResourceControllerV2.Response<ResourceControllerV2.ResourceInstance>>} */ ResourceControllerV2.prototype.cancelLastopResourceInstance = function (params) { var _params = __assign({}, params); var _requiredParams = ['id']; var _validParams = ['id', '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)(ResourceControllerV2.DEFAULT_SERVICE_NAME, 'v2', 'cancelLastopResourceInstance'); var parameters = { options: { url: '/v2/resource_instances/{id}/last_operation', method: 'DELETE', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', }, _params.headers), }), }; return this.createRequest(parameters); }; /************************* * resourceKeys ************************/ /** * Get a list of all of the resource keys. * * View all of the resource keys that exist for all of your resource instances. * * @param {Object} [params] - The parameters to send to the service. * @param {string} [params.guid] - The GUID of the key. * @param {string} [params.name] - The human-readable name of the key. * @param {string} [params.resourceGroupId] - The ID of the resource group. * @param {string} [params.resourceId] - The unique ID of the offering. This value is provided by and stored in the * global catalog. * @param {number} [params.limit] - Limit on how many items should be returned. * @param {string} [params.start] - An optional token that indicates the beginning of the page of results to be * returned. Any additional query parameters are ignored if a page token is present. If omitted, the first page of * results is returned. This value is obtained from the 'start' query parameter in the 'next_url' field of the * operation response. * @param {string} [params.updatedFrom] - Start date inclusive filter. * @param {string} [params.updatedTo] - End date inclusive filter. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ResourceControllerV2.Response<ResourceControllerV2.ResourceKeysList>>} */ ResourceControllerV2.prototype.listResourceKeys = function (params) { var _params = __assign({}, params); var _requiredParams = []; var _validParams = [ 'guid', 'name', 'resourceGroupId', 'resourceId', 'limit', 'start', 'updatedFrom', 'updatedTo', 'headers', ]; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var query = { 'guid': _params.guid, 'name': _params.name, 'resource_group_id': _params.resourceGroupId, 'resource_id': _params.resourceId, 'limit': _params.limit, 'start': _params.start, 'updated_from': _params.updatedFrom, 'updated_to': _params.updatedTo, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ResourceControllerV2.DEFAULT_SERVICE_NAME, 'v2', 'listResourceKeys'); var parameters = { options: { url: '/v2/resource_keys', method: 'GET', qs: query, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', }, _params.headers), }), }; return this.createRequest(parameters); }; /** * Create a new resource key. * * A resource key is a saved credential you can use to authenticate with a resource instance. * * @param {Object} params - The parameters to send to the service. * @param {string} params.name - The name of the key. * @param {string} params.source - The ID of resource instance or alias. * @param {ResourceKeyPostParameters} [params.parameters] - Configuration options represented as key-value pairs. * Service defined options are passed through to the target resource brokers, whereas platform defined options are * not. * @param {string} [params.role] - The base IAM service role name (Reader, Writer, or Manager), or the service or * custom role CRN. Refer to service’s documentation for supported roles. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ResourceControllerV2.Response<ResourceControllerV2.ResourceKey>>} */ ResourceControllerV2.prototype.createResourceKey = function (params) { var _params = __assign({}, params); var _requiredParams = ['name', 'source']; var _validParams = ['name', 'source', 'parameters', 'role', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = { 'name': _params.name, 'source': _params.source, 'parameters': _params.parameters, 'role': _params.role, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ResourceControllerV2.DEFAULT_SERVICE_NAME, 'v2', 'createResourceKey'); var parameters = { options: { url: '/v2/resource_keys', method: 'POST', body: body, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', 'Content-Type': 'application/json', }, _params.headers), }), }; return this.createRequest(parameters); }; /** * Get resource key. * * View the details of a resource key by URL-encoded CRN or GUID, like the credentials for the key and who created it. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - The resource key URL-encoded CRN or GUID. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ResourceControllerV2.Response<ResourceControllerV2.ResourceKey>>} */ ResourceControllerV2.prototype.getResourceKey = function (params) { var _params = __assign({}, params); var _requiredParams = ['id']; var _validParams = ['id', '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)(ResourceControllerV2.DEFAULT_SERVICE_NAME, 'v2', 'getResourceKey'); var parameters = { options: { url: '/v2/resource_keys/{id}', method: 'GET', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', }, _params.headers), }), }; return this.createRequest(parameters); }; /** * Delete a resource key. * * Deleting a resource key does not affect any resource instance or resource alias associated with the key. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - The resource key URL-encoded CRN or GUID. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ResourceControllerV2.Response<ResourceControllerV2.EmptyObject>>} */ ResourceControllerV2.prototype.deleteResourceKey = function (params) { var _params = __assign({}, params); var _requiredParams = ['id']; var _validParams = ['id', '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)(ResourceControllerV2.DEFAULT_SERVICE_NAME, 'v2', 'deleteResourceKey'); var parameters = { options: { url: '/v2/resource_keys/{id}', method: 'DELETE', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, {}, _params.headers), }), }; return this.createRequest(parameters); }; /** * Update a resource key. * * Use the resource key URL-encoded CRN or GUID to update the resource key. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - The resource key URL-encoded CRN or GUID. * @param {string} params.name - The new name of the key. Must be 180 characters or less and cannot include any * special characters other than `(space) - . _ :`. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ResourceControllerV2.Response<ResourceControllerV2.ResourceKey>>} */ ResourceControllerV2.prototype.updateResourceKey = function (params) { var _params = __assign({}, params); var _requiredParams = ['id', 'name']; var _validParams = ['id', 'name', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = { 'name': _params.name, }; var path = { 'id': _params.id, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ResourceControllerV2.DEFAULT_SERVICE_NAME, 'v2', 'updateResourceKey'); var parameters = { options: { url: '/v2/resource_keys/{id}', method: 'PATCH', body: body, path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', 'Content-Type': 'application/json', }, _params.headers), }), }; return this.createRequest(parameters); }; /************************* * resourceBindings ************************/ /** * Get a list of all resource bindings. * * View all of the resource bindings that exist for all of your resource aliases. * * @param {Object} [params] - The parameters to send to the service. * @param {string} [params.guid] - The GUID of the binding. * @param {string} [params.name] - The human-readable name of the binding. * @param {string} [params.resourceGroupId] - The ID of the resource group. * @param {string} [params.resourceId] - The unique ID of the offering (service name). This value is provided by and * stored in the global catalog. * @param {string} [params.regionBindingId] - The ID of the binding in the target environment. For example, * `service_binding_id` in a given IBM Cloud environment. * @param {number} [params.limit] - Limit on how many items should be returned. * @param {string} [params.start] - An optional token that indicates the beginning of the page of results to be * returned. Any additional query parameters are ignored if a page token is present. If omitted, the first page of * results is returned. This value is obtained from the 'start' query parameter in the 'next_url' field of the * operation response. * @param {string} [params.updatedFrom] - Start date inclusive filter. * @param {string} [params.updatedTo] - End date inclusive filter. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ResourceControllerV2.Response<ResourceControllerV2.ResourceBindingsList>>} * @deprecated this method is deprecated and may be removed in a future release */ ResourceControllerV2.prototype.listResourceBindings = function (params) { ResourceControllerV2._logger.warn('A deprecated operation has been invoked: listResourceBindings'); var _params = __assign({}, params); var _requiredParams = []; var _validParams = [ 'guid', 'name', 'resourceGroupId', 'resourceId', 'regionBindingId', 'limit', 'start', 'updatedFrom', 'updatedTo', 'headers', ]; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var query = { 'guid': _params.guid, 'name': _params.name, 'resource_group_id': _params.resourceGroupId, 'resource_id': _params.resourceId, 'region_binding_id': _params.regionBindingId, 'limit': _params.limit, 'start': _params.start, 'updated_from': _params.updatedFrom, 'updated_to': _params.updatedTo, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ResourceControllerV2.DEFAULT_SERVICE_NAME, 'v2', 'listResourceBindings'); var parameters = { options: { url: '/v2/resource_bindings', method: 'GET', qs: query, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', }, _params.headers), }), }; return this.createRequest(parameters); }; /** * Create a new resource binding. * * A resource binding connects credentials to a resource alias. The credentials are in the form of a resource key. * * @param {Object} params - The parameters to send to the service. * @param {string} params.source - The ID of resource alias. * @param {string} params.target - The CRN of application to bind to in a specific environment, for example, Dallas * YP, CFEE instance. * @param {string} [params.name] - The name of the binding. Must be 180 characters or less and cannot include any * special characters other than `(space) - . _ :`. * @param {ResourceBindingPostParameters} [params.parameters] - Configuration options represented as key-value pairs. * Service defined options are passed through to the target resource brokers, whereas platform defined options are * not. * @param {string} [params.role] - The base IAM service role name (Reader, Writer, or Manager), or the service or * custom role CRN. Refer to service’s documentation for supported roles. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ResourceControllerV2.Response<ResourceControllerV2.ResourceBinding>>} * @deprecated this method is deprecated and may be removed in a future release */ ResourceControllerV2.prototype.createResourceBinding = function (params) { ResourceControllerV2._logger.warn('A deprecated operation has been invoked: createResourceBinding'); var _params = __assign({}, params); var _requiredParams = ['source', 'target']; var _validParams = ['source', 'target', 'name', 'parameters', 'role', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = { 'source': _params.source, 'target': _params.target, 'name': _params.name, 'parameters': _params.parameters, 'role': _params.role, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ResourceControllerV2.DEFAULT_SERVICE_NAME, 'v2', 'createResourceBinding'); var parameters = { options: { url: '/v2/resource_bindings', method: 'POST', body: body, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', 'Content-Type': 'application/json', }, _params.headers), }), }; return this.createRequest(parameters); }; /** * Get a resource binding. * * View a resource binding and all of its details, like who created it, the credential, and the resource alias that * the binding is associated with. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - The resource binding URL-encoded CRN or GUID. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ResourceControllerV2.Response<ResourceControllerV2.ResourceBinding>>} * @deprecated this method is deprecated and may be removed in a future release */ ResourceControllerV2.prototype.getResourceBinding = function (params) { ResourceControllerV2._logger.warn('A deprecated operation has been invoked: getResourceBinding'); var _params = __assign({}, params); var _requiredParams = ['id']; var _validParams = ['id', '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)(ResourceControllerV2.DEFAULT_SERVICE_NAME, 'v2', 'getResourceBinding'); var parameters = { options: { url: '/v2/resource_bindings/{id}', method: 'GET', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', }, _params.headers), }), }; return this.createRequest(parameters); }; /** * Delete a resource binding. * * Deleting a resource binding does not affect the resource alias that the binding is associated with. * * @param {Object} params - The parameters to send to the service. * @param {string} params.id - The resource binding URL-encoded CRN or GUID. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ResourceControllerV2.Response<ResourceControllerV2.EmptyObject>>} * @deprecated this method is deprecated and may be removed in a future release */ ResourceControllerV2.prototype.deleteResourceBinding = function (params) { ResourceControllerV2._logger.warn('A deprecated operation has been invoked: deleteResourceBinding'); var _params = __assign({}, params); var _requiredParams = ['id']; var _validParams = ['id', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams);