UNPKG

@ibm-cloud/platform-services

Version:

Node.js client library for IBM Cloud Platform Services

973 lines 54.4 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); }; /** * IBM OpenAPI SDK Code Generator Version: 3.86.0-bc6f14b3-20240221-193958 */ var extend = require("extend"); var ibm_cloud_sdk_core_1 = require("ibm-cloud-sdk-core"); var common_1 = require("../lib/common"); /** * With the Context Based Restrictions API, you can: * * Create, list, get, replace, and delete network zones * * Create, list, get, replace, and delete context-based restriction rules * * Get account settings * * API Version: 1.0.1 */ var ContextBasedRestrictionsV1 = /** @class */ (function (_super) { __extends(ContextBasedRestrictionsV1, _super); /** * Construct a ContextBasedRestrictionsV1 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 {ContextBasedRestrictionsV1} */ function ContextBasedRestrictionsV1(options) { var _this = this; options = options || {}; _this = _super.call(this, options) || this; if (options.serviceUrl) { _this.setServiceUrl(options.serviceUrl); } else { _this.setServiceUrl(ContextBasedRestrictionsV1.DEFAULT_SERVICE_URL); } return _this; } /************************* * Factory method ************************/ /** * Constructs an instance of ContextBasedRestrictionsV1 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 {ContextBasedRestrictionsV1} */ ContextBasedRestrictionsV1.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 ContextBasedRestrictionsV1(options); service.configureService(options.serviceName); if (options.serviceUrl) { service.setServiceUrl(options.serviceUrl); } return service; }; /************************* * zones ************************/ /** * Create a network zone. * * This operation creates a network zone for the specified account. * * @param {Object} [params] - The parameters to send to the service. * @param {string} [params.name] - The name of the zone. * @param {string} [params.accountId] - The id of the account owning this zone. * @param {Address[]} [params.addresses] - The list of addresses in the zone. * @param {string} [params.description] - The description of the zone. * @param {Address[]} [params.excluded] - The list of excluded addresses in the zone. Only addresses of type * `ipAddress`, `ipRange`, and `subnet` can be excluded. * @param {string} [params.xCorrelationId] - The supplied or generated value of this header is logged for a request * and repeated in a response header for the corresponding response. The same value is used for downstream requests * and retries of those requests. If a value of this headers is not supplied in a request, the service generates a * random (version 4) UUID. * @param {string} [params.transactionId] - Deprecated: The `Transaction-Id` header behaves as the `X-Correlation-Id` * header. It is supported for backward compatibility with other IBM platform services that support the * `Transaction-Id` header only. If both `X-Correlation-Id` and `Transaction-Id` are provided, `X-Correlation-Id` has * the precedence over `Transaction-Id`. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ContextBasedRestrictionsV1.Response<ContextBasedRestrictionsV1.Zone>>} */ ContextBasedRestrictionsV1.prototype.createZone = function (params) { var _params = __assign({}, params); var _requiredParams = []; var _validParams = [ 'name', 'accountId', 'addresses', 'description', 'excluded', 'xCorrelationId', 'transactionId', 'headers', ]; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = { 'name': _params.name, 'account_id': _params.accountId, 'addresses': _params.addresses, 'description': _params.description, 'excluded': _params.excluded, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ContextBasedRestrictionsV1.DEFAULT_SERVICE_NAME, 'v1', 'createZone'); var parameters = { options: { url: '/v1/zones', method: 'POST', body: body, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', 'Content-Type': 'application/json', 'X-Correlation-Id': _params.xCorrelationId, 'Transaction-Id': _params.transactionId, }, _params.headers), }), }; return this.createRequest(parameters); }; /** * List network zones. * * This operation lists network zones in the specified account. * * @param {Object} params - The parameters to send to the service. * @param {string} params.accountId - The ID of the managing account. * @param {string} [params.xCorrelationId] - The supplied or generated value of this header is logged for a request * and repeated in a response header for the corresponding response. The same value is used for downstream requests * and retries of those requests. If a value of this headers is not supplied in a request, the service generates a * random (version 4) UUID. * @param {string} [params.transactionId] - Deprecated: The `Transaction-Id` header behaves as the `X-Correlation-Id` * header. It is supported for backward compatibility with other IBM platform services that support the * `Transaction-Id` header only. If both `X-Correlation-Id` and `Transaction-Id` are provided, `X-Correlation-Id` has * the precedence over `Transaction-Id`. * @param {string} [params.name] - The name of the zone. * @param {string} [params.sort] - Sorts results by using a valid sort field. To learn more, see * [Sorting](https://cloud.ibm.com/docs/api-handbook?topic=api-handbook-sorting). * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ContextBasedRestrictionsV1.Response<ContextBasedRestrictionsV1.ZoneList>>} */ ContextBasedRestrictionsV1.prototype.listZones = function (params) { var _params = __assign({}, params); var _requiredParams = ['accountId']; var _validParams = [ 'accountId', 'xCorrelationId', 'transactionId', 'name', 'sort', '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, 'name': _params.name, 'sort': _params.sort, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ContextBasedRestrictionsV1.DEFAULT_SERVICE_NAME, 'v1', 'listZones'); var parameters = { options: { url: '/v1/zones', method: 'GET', qs: query, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', 'X-Correlation-Id': _params.xCorrelationId, 'Transaction-Id': _params.transactionId, }, _params.headers), }), }; return this.createRequest(parameters); }; /** * Get a network zone. * * This operation retrieves the network zone identified by the specified zone ID. * * @param {Object} params - The parameters to send to the service. * @param {string} params.zoneId - The ID of a zone. * @param {string} [params.xCorrelationId] - The supplied or generated value of this header is logged for a request * and repeated in a response header for the corresponding response. The same value is used for downstream requests * and retries of those requests. If a value of this headers is not supplied in a request, the service generates a * random (version 4) UUID. * @param {string} [params.transactionId] - Deprecated: The `Transaction-Id` header behaves as the `X-Correlation-Id` * header. It is supported for backward compatibility with other IBM platform services that support the * `Transaction-Id` header only. If both `X-Correlation-Id` and `Transaction-Id` are provided, `X-Correlation-Id` has * the precedence over `Transaction-Id`. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ContextBasedRestrictionsV1.Response<ContextBasedRestrictionsV1.Zone>>} */ ContextBasedRestrictionsV1.prototype.getZone = function (params) { var _params = __assign({}, params); var _requiredParams = ['zoneId']; var _validParams = ['zoneId', 'xCorrelationId', 'transactionId', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var path = { 'zone_id': _params.zoneId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ContextBasedRestrictionsV1.DEFAULT_SERVICE_NAME, 'v1', 'getZone'); var parameters = { options: { url: '/v1/zones/{zone_id}', method: 'GET', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', 'X-Correlation-Id': _params.xCorrelationId, 'Transaction-Id': _params.transactionId, }, _params.headers), }), }; return this.createRequest(parameters); }; /** * Replace a network zone. * * This operation replaces the network zone identified by the specified zone ID. Partial updates are not supported. * The entire network zone object must be replaced. * * @param {Object} params - The parameters to send to the service. * @param {string} params.zoneId - The ID of a zone. * @param {string} params.ifMatch - The current revision of the resource being updated. This can be found in the * Create/Get/Update resource response ETag header. * @param {string} [params.name] - The name of the zone. * @param {string} [params.accountId] - The id of the account owning this zone. * @param {Address[]} [params.addresses] - The list of addresses in the zone. * @param {string} [params.description] - The description of the zone. * @param {Address[]} [params.excluded] - The list of excluded addresses in the zone. Only addresses of type * `ipAddress`, `ipRange`, and `subnet` can be excluded. * @param {string} [params.xCorrelationId] - The supplied or generated value of this header is logged for a request * and repeated in a response header for the corresponding response. The same value is used for downstream requests * and retries of those requests. If a value of this headers is not supplied in a request, the service generates a * random (version 4) UUID. * @param {string} [params.transactionId] - Deprecated: The `Transaction-Id` header behaves as the `X-Correlation-Id` * header. It is supported for backward compatibility with other IBM platform services that support the * `Transaction-Id` header only. If both `X-Correlation-Id` and `Transaction-Id` are provided, `X-Correlation-Id` has * the precedence over `Transaction-Id`. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ContextBasedRestrictionsV1.Response<ContextBasedRestrictionsV1.Zone>>} */ ContextBasedRestrictionsV1.prototype.replaceZone = function (params) { var _params = __assign({}, params); var _requiredParams = ['zoneId', 'ifMatch']; var _validParams = [ 'zoneId', 'ifMatch', 'name', 'accountId', 'addresses', 'description', 'excluded', 'xCorrelationId', 'transactionId', 'headers', ]; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = { 'name': _params.name, 'account_id': _params.accountId, 'addresses': _params.addresses, 'description': _params.description, 'excluded': _params.excluded, }; var path = { 'zone_id': _params.zoneId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ContextBasedRestrictionsV1.DEFAULT_SERVICE_NAME, 'v1', 'replaceZone'); var parameters = { options: { url: '/v1/zones/{zone_id}', method: 'PUT', body: body, path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', 'Content-Type': 'application/json', 'If-Match': _params.ifMatch, 'X-Correlation-Id': _params.xCorrelationId, 'Transaction-Id': _params.transactionId, }, _params.headers), }), }; return this.createRequest(parameters); }; /** * Delete a network zone. * * This operation deletes the network zone identified by the specified zone ID. * * @param {Object} params - The parameters to send to the service. * @param {string} params.zoneId - The ID of a zone. * @param {string} [params.xCorrelationId] - The supplied or generated value of this header is logged for a request * and repeated in a response header for the corresponding response. The same value is used for downstream requests * and retries of those requests. If a value of this headers is not supplied in a request, the service generates a * random (version 4) UUID. * @param {string} [params.transactionId] - Deprecated: The `Transaction-Id` header behaves as the `X-Correlation-Id` * header. It is supported for backward compatibility with other IBM platform services that support the * `Transaction-Id` header only. If both `X-Correlation-Id` and `Transaction-Id` are provided, `X-Correlation-Id` has * the precedence over `Transaction-Id`. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ContextBasedRestrictionsV1.Response<ContextBasedRestrictionsV1.EmptyObject>>} */ ContextBasedRestrictionsV1.prototype.deleteZone = function (params) { var _params = __assign({}, params); var _requiredParams = ['zoneId']; var _validParams = ['zoneId', 'xCorrelationId', 'transactionId', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var path = { 'zone_id': _params.zoneId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ContextBasedRestrictionsV1.DEFAULT_SERVICE_NAME, 'v1', 'deleteZone'); var parameters = { options: { url: '/v1/zones/{zone_id}', method: 'DELETE', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'X-Correlation-Id': _params.xCorrelationId, 'Transaction-Id': _params.transactionId, }, _params.headers), }), }; return this.createRequest(parameters); }; /** * List available service reference targets. * * This operation lists all available service reference targets. * * @param {Object} [params] - The parameters to send to the service. * @param {string} [params.xCorrelationId] - The supplied or generated value of this header is logged for a request * and repeated in a response header for the corresponding response. The same value is used for downstream requests * and retries of those requests. If a value of this headers is not supplied in a request, the service generates a * random (version 4) UUID. * @param {string} [params.transactionId] - Deprecated: The `Transaction-Id` header behaves as the `X-Correlation-Id` * header. It is supported for backward compatibility with other IBM platform services that support the * `Transaction-Id` header only. If both `X-Correlation-Id` and `Transaction-Id` are provided, `X-Correlation-Id` has * the precedence over `Transaction-Id`. * @param {string} [params.type] - Specifies the types of services to retrieve. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ContextBasedRestrictionsV1.Response<ContextBasedRestrictionsV1.ServiceRefTargetList>>} */ ContextBasedRestrictionsV1.prototype.listAvailableServicerefTargets = function (params) { var _params = __assign({}, params); var _requiredParams = []; var _validParams = ['xCorrelationId', 'transactionId', 'type', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var query = { 'type': _params.type, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ContextBasedRestrictionsV1.DEFAULT_SERVICE_NAME, 'v1', 'listAvailableServicerefTargets'); var parameters = { options: { url: '/v1/zones/serviceref_targets', method: 'GET', qs: query, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', 'X-Correlation-Id': _params.xCorrelationId, 'Transaction-Id': _params.transactionId, }, _params.headers), }), }; return this.createRequest(parameters); }; /** * Get service reference target for a specified service name. * * This operation gets the service reference target for a specified service name. * * @param {Object} params - The parameters to send to the service. * @param {string} params.serviceName - The name of a service. * @param {string} [params.xCorrelationId] - The supplied or generated value of this header is logged for a request * and repeated in a response header for the corresponding response. The same value is used for downstream requests * and retries of those requests. If a value of this headers is not supplied in a request, the service generates a * random (version 4) UUID. * @param {string} [params.transactionId] - Deprecated: The `Transaction-Id` header behaves as the `X-Correlation-Id` * header. It is supported for backward compatibility with other IBM platform services that support the * `Transaction-Id` header only. If both `X-Correlation-Id` and `Transaction-Id` are provided, `X-Correlation-Id` has * the precedence over `Transaction-Id`. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ContextBasedRestrictionsV1.Response<ContextBasedRestrictionsV1.ServiceRefTarget>>} */ ContextBasedRestrictionsV1.prototype.getServicerefTarget = function (params) { var _params = __assign({}, params); var _requiredParams = ['serviceName']; var _validParams = ['serviceName', 'xCorrelationId', 'transactionId', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var path = { 'service_name': _params.serviceName, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ContextBasedRestrictionsV1.DEFAULT_SERVICE_NAME, 'v1', 'getServicerefTarget'); var parameters = { options: { url: '/v1/zones/serviceref_targets/{service_name}', method: 'GET', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', 'X-Correlation-Id': _params.xCorrelationId, 'Transaction-Id': _params.transactionId, }, _params.headers), }), }; return this.createRequest(parameters); }; /************************* * rules ************************/ /** * Create a rule. * * This operation creates a rule for the specified account. * * @param {Object} [params] - The parameters to send to the service. * @param {RuleContext[]} [params.contexts] - The contexts this rule applies to. * @param {Resource[]} [params.resources] - The resources this rule apply to. * @param {string} [params.description] - The description of the rule. * @param {NewRuleOperations} [params.operations] - The operations this rule applies to. * @param {string} [params.enforcementMode] - The rule enforcement mode: * * `enabled` - The restrictions are enforced and reported. This is the default. * * `disabled` - The restrictions are disabled. Nothing is enforced or reported. * * `report` - The restrictions are evaluated and reported, but not enforced. * @param {string} [params.xCorrelationId] - The supplied or generated value of this header is logged for a request * and repeated in a response header for the corresponding response. The same value is used for downstream requests * and retries of those requests. If a value of this headers is not supplied in a request, the service generates a * random (version 4) UUID. * @param {string} [params.transactionId] - Deprecated: The `Transaction-Id` header behaves as the `X-Correlation-Id` * header. It is supported for backward compatibility with other IBM platform services that support the * `Transaction-Id` header only. If both `X-Correlation-Id` and `Transaction-Id` are provided, `X-Correlation-Id` has * the precedence over `Transaction-Id`. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ContextBasedRestrictionsV1.Response<ContextBasedRestrictionsV1.Rule>>} */ ContextBasedRestrictionsV1.prototype.createRule = function (params) { var _params = __assign({}, params); var _requiredParams = []; var _validParams = [ 'contexts', 'resources', 'description', 'operations', 'enforcementMode', 'xCorrelationId', 'transactionId', 'headers', ]; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = { 'contexts': _params.contexts, 'resources': _params.resources, 'description': _params.description, 'operations': _params.operations, 'enforcement_mode': _params.enforcementMode, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ContextBasedRestrictionsV1.DEFAULT_SERVICE_NAME, 'v1', 'createRule'); var parameters = { options: { url: '/v1/rules', method: 'POST', body: body, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', 'Content-Type': 'application/json', 'X-Correlation-Id': _params.xCorrelationId, 'Transaction-Id': _params.transactionId, }, _params.headers), }), }; return this.createRequest(parameters); }; /** * List rules. * * This operation lists rules in the specified account. * * @param {Object} params - The parameters to send to the service. * @param {string} params.accountId - The ID of the managing account. * @param {string} [params.xCorrelationId] - The supplied or generated value of this header is logged for a request * and repeated in a response header for the corresponding response. The same value is used for downstream requests * and retries of those requests. If a value of this headers is not supplied in a request, the service generates a * random (version 4) UUID. * @param {string} [params.transactionId] - Deprecated: The `Transaction-Id` header behaves as the `X-Correlation-Id` * header. It is supported for backward compatibility with other IBM platform services that support the * `Transaction-Id` header only. If both `X-Correlation-Id` and `Transaction-Id` are provided, `X-Correlation-Id` has * the precedence over `Transaction-Id`. * @param {string} [params.region] - The `region` resource attribute. * @param {string} [params.resource] - The `resource` resource attribute. * @param {string} [params.resourceType] - The `resourceType` resource attribute. * @param {string} [params.serviceInstance] - The `serviceInstance` resource attribute. * @param {string} [params.serviceName] - The `serviceName` resource attribute. * @param {string} [params.serviceType] - The rule's `serviceType` resource attribute. * @param {string} [params.serviceGroupId] - The rule's `service_group_id` resource attribute. * @param {string} [params.zoneId] - The globally unique ID of the zone. * @param {string} [params.sort] - Sorts results by using a valid sort field. To learn more, see * [Sorting](https://cloud.ibm.com/docs/api-handbook?topic=api-handbook-sorting). * @param {string} [params.enforcementMode] - The rule's `enforcement_mode` attribute. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ContextBasedRestrictionsV1.Response<ContextBasedRestrictionsV1.RuleList>>} */ ContextBasedRestrictionsV1.prototype.listRules = function (params) { var _params = __assign({}, params); var _requiredParams = ['accountId']; var _validParams = [ 'accountId', 'xCorrelationId', 'transactionId', 'region', 'resource', 'resourceType', 'serviceInstance', 'serviceName', 'serviceType', 'serviceGroupId', 'zoneId', 'sort', 'enforcementMode', '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, 'region': _params.region, 'resource': _params.resource, 'resource_type': _params.resourceType, 'service_instance': _params.serviceInstance, 'service_name': _params.serviceName, 'service_type': _params.serviceType, 'service_group_id': _params.serviceGroupId, 'zone_id': _params.zoneId, 'sort': _params.sort, 'enforcement_mode': _params.enforcementMode, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ContextBasedRestrictionsV1.DEFAULT_SERVICE_NAME, 'v1', 'listRules'); var parameters = { options: { url: '/v1/rules', method: 'GET', qs: query, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', 'X-Correlation-Id': _params.xCorrelationId, 'Transaction-Id': _params.transactionId, }, _params.headers), }), }; return this.createRequest(parameters); }; /** * Get a rule. * * This operation retrieves the rule identified by the specified rule ID. * * @param {Object} params - The parameters to send to the service. * @param {string} params.ruleId - The ID of a rule. * @param {string} [params.xCorrelationId] - The supplied or generated value of this header is logged for a request * and repeated in a response header for the corresponding response. The same value is used for downstream requests * and retries of those requests. If a value of this headers is not supplied in a request, the service generates a * random (version 4) UUID. * @param {string} [params.transactionId] - Deprecated: The `Transaction-Id` header behaves as the `X-Correlation-Id` * header. It is supported for backward compatibility with other IBM platform services that support the * `Transaction-Id` header only. If both `X-Correlation-Id` and `Transaction-Id` are provided, `X-Correlation-Id` has * the precedence over `Transaction-Id`. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ContextBasedRestrictionsV1.Response<ContextBasedRestrictionsV1.Rule>>} */ ContextBasedRestrictionsV1.prototype.getRule = function (params) { var _params = __assign({}, params); var _requiredParams = ['ruleId']; var _validParams = ['ruleId', 'xCorrelationId', 'transactionId', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var path = { 'rule_id': _params.ruleId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ContextBasedRestrictionsV1.DEFAULT_SERVICE_NAME, 'v1', 'getRule'); var parameters = { options: { url: '/v1/rules/{rule_id}', method: 'GET', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', 'X-Correlation-Id': _params.xCorrelationId, 'Transaction-Id': _params.transactionId, }, _params.headers), }), }; return this.createRequest(parameters); }; /** * Replace a rule. * * This operation replaces the rule identified by the specified rule ID. Partial updates are not supported. The entire * rule object must be replaced. * * @param {Object} params - The parameters to send to the service. * @param {string} params.ruleId - The ID of a rule. * @param {string} params.ifMatch - The current revision of the resource being updated. This can be found in the * Create/Get/Update resource response ETag header. * @param {RuleContext[]} [params.contexts] - The contexts this rule applies to. * @param {Resource[]} [params.resources] - The resources this rule apply to. * @param {string} [params.description] - The description of the rule. * @param {NewRuleOperations} [params.operations] - The operations this rule applies to. * @param {string} [params.enforcementMode] - The rule enforcement mode: * * `enabled` - The restrictions are enforced and reported. This is the default. * * `disabled` - The restrictions are disabled. Nothing is enforced or reported. * * `report` - The restrictions are evaluated and reported, but not enforced. * @param {string} [params.xCorrelationId] - The supplied or generated value of this header is logged for a request * and repeated in a response header for the corresponding response. The same value is used for downstream requests * and retries of those requests. If a value of this headers is not supplied in a request, the service generates a * random (version 4) UUID. * @param {string} [params.transactionId] - Deprecated: The `Transaction-Id` header behaves as the `X-Correlation-Id` * header. It is supported for backward compatibility with other IBM platform services that support the * `Transaction-Id` header only. If both `X-Correlation-Id` and `Transaction-Id` are provided, `X-Correlation-Id` has * the precedence over `Transaction-Id`. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ContextBasedRestrictionsV1.Response<ContextBasedRestrictionsV1.Rule>>} */ ContextBasedRestrictionsV1.prototype.replaceRule = function (params) { var _params = __assign({}, params); var _requiredParams = ['ruleId', 'ifMatch']; var _validParams = [ 'ruleId', 'ifMatch', 'contexts', 'resources', 'description', 'operations', 'enforcementMode', 'xCorrelationId', 'transactionId', 'headers', ]; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = { 'contexts': _params.contexts, 'resources': _params.resources, 'description': _params.description, 'operations': _params.operations, 'enforcement_mode': _params.enforcementMode, }; var path = { 'rule_id': _params.ruleId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ContextBasedRestrictionsV1.DEFAULT_SERVICE_NAME, 'v1', 'replaceRule'); var parameters = { options: { url: '/v1/rules/{rule_id}', method: 'PUT', body: body, path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', 'Content-Type': 'application/json', 'If-Match': _params.ifMatch, 'X-Correlation-Id': _params.xCorrelationId, 'Transaction-Id': _params.transactionId, }, _params.headers), }), }; return this.createRequest(parameters); }; /** * Delete a rule. * * This operation deletes the rule identified by the specified rule ID. * * @param {Object} params - The parameters to send to the service. * @param {string} params.ruleId - The ID of a rule. * @param {string} [params.xCorrelationId] - The supplied or generated value of this header is logged for a request * and repeated in a response header for the corresponding response. The same value is used for downstream requests * and retries of those requests. If a value of this headers is not supplied in a request, the service generates a * random (version 4) UUID. * @param {string} [params.transactionId] - Deprecated: The `Transaction-Id` header behaves as the `X-Correlation-Id` * header. It is supported for backward compatibility with other IBM platform services that support the * `Transaction-Id` header only. If both `X-Correlation-Id` and `Transaction-Id` are provided, `X-Correlation-Id` has * the precedence over `Transaction-Id`. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ContextBasedRestrictionsV1.Response<ContextBasedRestrictionsV1.EmptyObject>>} */ ContextBasedRestrictionsV1.prototype.deleteRule = function (params) { var _params = __assign({}, params); var _requiredParams = ['ruleId']; var _validParams = ['ruleId', 'xCorrelationId', 'transactionId', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var path = { 'rule_id': _params.ruleId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ContextBasedRestrictionsV1.DEFAULT_SERVICE_NAME, 'v1', 'deleteRule'); var parameters = { options: { url: '/v1/rules/{rule_id}', method: 'DELETE', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'X-Correlation-Id': _params.xCorrelationId, 'Transaction-Id': _params.transactionId, }, _params.headers), }), }; return this.createRequest(parameters); }; /************************* * accountSettings ************************/ /** * Get account settings. * * This operation retrieves the settings for the specified account ID. * * @param {Object} params - The parameters to send to the service. * @param {string} params.accountId - The ID of the account the settings are for. * @param {string} [params.xCorrelationId] - The supplied or generated value of this header is logged for a request * and repeated in a response header for the corresponding response. The same value is used for downstream requests * and retries of those requests. If a value of this headers is not supplied in a request, the service generates a * random (version 4) UUID. * @param {string} [params.transactionId] - Deprecated: The `Transaction-Id` header behaves as the `X-Correlation-Id` * header. It is supported for backward compatibility with other IBM platform services that support the * `Transaction-Id` header only. If both `X-Correlation-Id` and `Transaction-Id` are provided, `X-Correlation-Id` has * the precedence over `Transaction-Id`. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ContextBasedRestrictionsV1.Response<ContextBasedRestrictionsV1.AccountSettings>>} */ ContextBasedRestrictionsV1.prototype.getAccountSettings = function (params) { var _params = __assign({}, params); var _requiredParams = ['accountId']; var _validParams = ['accountId', 'xCorrelationId', 'transactionId', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var path = { 'account_id': _params.accountId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ContextBasedRestrictionsV1.DEFAULT_SERVICE_NAME, 'v1', 'getAccountSettings'); var parameters = { options: { url: '/v1/account_settings/{account_id}', method: 'GET', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', 'X-Correlation-Id': _params.xCorrelationId, 'Transaction-Id': _params.transactionId, }, _params.headers), }), }; return this.createRequest(parameters); }; /************************* * operations ************************/ /** * List available service operations. * * This operation lists all available service operations. * * @param {Object} [params] - The parameters to send to the service. * @param {string} [params.xCorrelationId] - The supplied or generated value of this header is logged for a request * and repeated in a response header for the corresponding response. The same value is used for downstream requests * and retries of those requests. If a value of this headers is not supplied in a request, the service generates a * random (version 4) UUID. * @param {string} [params.transactionId] - Deprecated: The `Transaction-Id` header behaves as the `X-Correlation-Id` * header. It is supported for backward compatibility with other IBM platform services that support the * `Transaction-Id` header only. If both `X-Correlation-Id` and `Transaction-Id` are provided, `X-Correlation-Id` has * the precedence over `Transaction-Id`. * @param {string} [params.serviceName] - The name of the service. * @param {string} [params.serviceGroupId] - The id of the service group. * @param {string} [params.resourceType] - The type of resource. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<ContextBasedRestrictionsV1.Response<ContextBasedRestrictionsV1.OperationsList>>} */ ContextBasedRestrictionsV1.prototype.listAvailableServiceOperations = function (params) { var _params = __assign({}, params); var _requiredParams = []; var _validParams = [ 'xCorrelationId', 'transactionId', 'serviceName', 'serviceGroupId', 'resourceType', 'headers', ]; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var query = { 'service_name': _params.serviceName, 'service_group_id': _params.serviceGroupId, 'resource_type': _params.resourceType, }; var sdkHeaders = (0, common_1.getSdkHeaders)(ContextBasedRestrictionsV1.DEFAULT_SERVICE_NAME, 'v1', 'listAvailableServiceOperations'); var parameters = { options: { url: '/v1/operations', method: 'GET', qs: query, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', 'X-Correlation-Id': _params.xCorrelationId, 'Transaction-Id': _params.transactionId, }, _params.headers), }), }; return this.createRequest(parameters); }; ContextBasedRestrictionsV1.DEFAULT_SERVICE_URL = 'https://cbr.cloud.ibm.com'; ContextBasedRestrictionsV1.DEFAULT_SERVICE_NAME = 'context_based_restrictions'; return ContextBasedRestrictionsV1; }(ibm_cloud_sdk_core_1.BaseService)); /************************* * interfaces ************************/ (function (ContextBasedRestrictionsV1) { /** Constants for the `listAvailableServicerefTargets` operation. */ var ListAvailableServicerefTargetsConstants; (function (ListAvailableServicerefTargetsConstants) { /** Specifies the types of services to retrieve. */ var Type; (function (Type) { Type["ALL"] = "all"; Type["PLATFORM_SERVICE"] = "platform_service"; })(Type = ListAvailableServicerefTargetsConstants.Type || (ListAvailableServicerefTargetsConstants.Type = {})); })(ListAvailableServicerefTargetsConstants = ContextBasedRestrictionsV1.ListAvailableServicerefTargetsConstants || (ContextBasedRestrictionsV1.ListAvailableServicerefTargetsConstants = {})); /** Constants for the `createRule` operation. */ var CreateRuleConstants; (function (CreateRuleConstants) { /** The rule enforcement mode: * `enabled` - The restrictions are enforced and reported. This is the default. * `disabled` - The restrictions are disabled. Nothing is enforced or reported. * `report` - The restrictions are evaluated and reported, but not enforced. */ var EnforcementMode; (function (EnforcementMode) { EnforcementMode["ENABLED"] = "enabled"; EnforcementMode["DISABLED"] = "disabled"; EnforcementMode["REPORT"] = "report"; })(EnforcementMode = CreateRuleConstants.EnforcementMode || (CreateRuleConstants.EnforcementMode = {})); })(CreateRuleConstants = ContextBasedRestrictionsV1.CreateRuleConstants || (ContextBasedRestrictionsV1.CreateRuleConstants = {})); /** Constants for the `listRules` operation. */ var ListRulesConstants; (function (ListRulesConstants) { /** The rule's `enforcement_mode` attribute. */ var EnforcementMode; (function (EnforcementMode) { EnforcementMode["ENABLED"] = "enabled"; EnforcementMode["DISABLED"] = "disabled"; EnforcementMode["REPORT"] = "report"; })(EnforcementMode = ListRulesConstants.EnforcementMode || (ListRulesConstants.EnforcementMode = {})); })(ListRulesConstants = ContextBasedRestrictionsV1.ListRulesConstants || (ContextBasedRestrictionsV1.ListRulesConstants = {})); /** Constants for the `replaceRule` operation. */ var ReplaceRuleConstants; (function (ReplaceRuleConstants) { /** The rule enforcement mode: * `enabled` - The restrictions are enforced and reported. This is the default. * `disabled` - The restrictions are disabled. Nothing is enforced or reported. * `report` - The restrictions are evaluated and reported, but not enforced. */ var EnforcementMode; (function (EnforcementMode) { EnforcementMode["ENABLED"] = "enabled"; EnforcementMode["DISABLED"] = "disabled"; EnforcementMode["REPORT"] = "report"; })(EnforcementMode = ReplaceRuleConstants.EnforcementMode || (ReplaceRuleConstants.EnforcementMode = {})); })(ReplaceRuleConstants = Context