UNPKG

@ibm-cloud/platform-services

Version:

Node.js client library for IBM Cloud Platform Services

987 lines 55.4 kB
"use strict"; /** * (C) Copyright IBM Corp. 2026. * * 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.108.0-56772134-20251111-102802 */ /* 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"); /** * API for IBM Cloud account notifications, providing capabilities to: * - View notifications * - Get and update acknowledgements * - Manage user communication preferences * - Manage notification distribution lists * * API Version: 1.0.0 */ var PlatformNotificationsV1 = /** @class */ (function (_super) { __extends(PlatformNotificationsV1, _super); /** * Construct a PlatformNotificationsV1 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 {PlatformNotificationsV1} */ function PlatformNotificationsV1(options) { var _this = this; options = options || {}; _this = _super.call(this, options) || this; if (options.serviceUrl) { _this.setServiceUrl(options.serviceUrl); } else { _this.setServiceUrl(PlatformNotificationsV1.DEFAULT_SERVICE_URL); } return _this; } /************************* * Factory method ************************/ /** * Constructs an instance of PlatformNotificationsV1 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 {PlatformNotificationsV1} */ PlatformNotificationsV1.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 PlatformNotificationsV1(options); service.configureService(options.serviceName); if (options.serviceUrl) { service.setServiceUrl(options.serviceUrl); } return service; }; /************************* * notifications ************************/ /** * Get user notifications. * * Retrieve all notifications for the requested user. * * @param {Object} [params] - The parameters to send to the service. * @param {string} [params.accountId] - The IBM Cloud account ID. If not provided, the account ID from the bearer * token will be used. * @param {string} [params.start] - An opaque page token that specifies the resource to start the page on or after. If * unspecified, the first page of results is returned. * @param {number} [params.limit] - The maximum number of items to return per page. If unspecified, a default limit of * 50 is used. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<PlatformNotificationsV1.Response<PlatformNotificationsV1.NotificationCollection>>} */ PlatformNotificationsV1.prototype.listNotifications = function (params) { var _params = __assign({}, params); var _requiredParams = []; var _validParams = ['accountId', 'start', 'limit', '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, 'start': _params.start, 'limit': _params.limit, }; var sdkHeaders = (0, common_1.getSdkHeaders)(PlatformNotificationsV1.DEFAULT_SERVICE_NAME, 'v1', 'listNotifications'); var parameters = { options: { url: '/v1/notifications', method: 'GET', qs: query, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Get acknowledgement. * * Retrieve the ID of the last notification acknowledged by the user for a specific account. * * @param {Object} [params] - The parameters to send to the service. * @param {string} [params.accountId] - The IBM Cloud account ID. If not provided, the account ID from the bearer * token will be used. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<PlatformNotificationsV1.Response<PlatformNotificationsV1.Acknowledgement>>} */ PlatformNotificationsV1.prototype.getAcknowledgement = 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)(PlatformNotificationsV1.DEFAULT_SERVICE_NAME, 'v1', 'getAcknowledgement'); var parameters = { options: { url: '/v1/notifications/acknowledgement', 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); }; /** * Update acknowledgement. * * Update the ID of the last notification acknowledged by the user for a specific account. * * @param {Object} params - The parameters to send to the service. * @param {number} params.lastAcknowledged - The timestamp of the last acknowledgement. * @param {string} [params.accountId] - The IBM Cloud account ID. If not provided, the account ID from the bearer * token will be used. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<PlatformNotificationsV1.Response<PlatformNotificationsV1.Acknowledgement>>} */ PlatformNotificationsV1.prototype.replaceNotificationAcknowledgement = function (params) { var _params = __assign({}, params); var _requiredParams = ['lastAcknowledged']; var _validParams = ['lastAcknowledged', 'accountId', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = { 'last_acknowledged': _params.lastAcknowledged, }; var query = { 'account_id': _params.accountId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(PlatformNotificationsV1.DEFAULT_SERVICE_NAME, 'v1', 'replaceNotificationAcknowledgement'); var parameters = { options: { url: '/v1/notifications/acknowledgement', method: 'PUT', body: body, qs: query, }, 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); }; /************************* * distributionLists ************************/ /** * Get all destination entries. * * Retrieve all destinations in the distribution list for the specified account. * * @param {Object} params - The parameters to send to the service. * @param {string} params.accountId - The IBM Cloud account ID. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<PlatformNotificationsV1.Response<PlatformNotificationsV1.AddDestinationCollection>>} */ PlatformNotificationsV1.prototype.listDistributionListDestinations = function (params) { var _params = __assign({}, params); var _requiredParams = ['accountId']; var _validParams = ['accountId', 'signal', '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)(PlatformNotificationsV1.DEFAULT_SERVICE_NAME, 'v1', 'listDistributionListDestinations'); var parameters = { options: { url: '/v1/distribution_lists/{account_id}/destinations', 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); }; /** * Add a destination entry. * * Add a destination entry to the distribution list. A maximum of 10 destination entries per destination type. In * terms of enterprise accounts, you can provide an Event Notifications destination that is from a different account * than the distribution list account, provided these two accounts are from the same enterprise and the user has * permission to manage the Event Notifications destinations on both accounts. * * @param {Object} params - The parameters to send to the service. * @param {string} params.accountId - The IBM Cloud account ID. * @param {AddDestinationPrototype} params.addDestinationPrototype - * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<PlatformNotificationsV1.Response<PlatformNotificationsV1.AddDestination>>} */ PlatformNotificationsV1.prototype.createDistributionListDestination = function (params) { var _params = __assign({}, params); var _requiredParams = ['accountId', 'addDestinationPrototype']; var _validParams = ['accountId', 'addDestinationPrototype', 'signal', 'headers']; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = _params.addDestinationPrototype; var path = { 'account_id': _params.accountId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(PlatformNotificationsV1.DEFAULT_SERVICE_NAME, 'v1', 'createDistributionListDestination'); var parameters = { options: { url: '/v1/distribution_lists/{account_id}/destinations', method: 'POST', body: body, path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', 'Content-Type': 'application/json', }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Get a destination entry. * * Retrieve a specific destination from the distribution list of the account. * * @param {Object} params - The parameters to send to the service. * @param {string} params.accountId - The IBM Cloud account ID. * @param {string} params.destinationId - The ID of the destination. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<PlatformNotificationsV1.Response<PlatformNotificationsV1.AddDestination>>} */ PlatformNotificationsV1.prototype.getDistributionListDestination = function (params) { var _params = __assign({}, params); var _requiredParams = ['accountId', 'destinationId']; var _validParams = ['accountId', 'destinationId', 'signal', '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, 'destination_id': _params.destinationId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(PlatformNotificationsV1.DEFAULT_SERVICE_NAME, 'v1', 'getDistributionListDestination'); var parameters = { options: { url: '/v1/distribution_lists/{account_id}/destinations/{destination_id}', method: 'GET', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Delete a destination entry. * * Remove a destination entry. * * @param {Object} params - The parameters to send to the service. * @param {string} params.accountId - The IBM Cloud account ID. * @param {string} params.destinationId - The ID of the destination. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<PlatformNotificationsV1.Response<PlatformNotificationsV1.EmptyObject>>} */ PlatformNotificationsV1.prototype.deleteDistributionListDestination = function (params) { var _params = __assign({}, params); var _requiredParams = ['accountId', 'destinationId']; var _validParams = ['accountId', 'destinationId', 'signal', '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, 'destination_id': _params.destinationId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(PlatformNotificationsV1.DEFAULT_SERVICE_NAME, 'v1', 'deleteDistributionListDestination'); var parameters = { options: { url: '/v1/distribution_lists/{account_id}/destinations/{destination_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); }; /** * Test a destination entry. * * Send a test notification to a destination in the distribution list. This allows you to verify that the destination * is properly configured and can receive notifications. * * @param {Object} params - The parameters to send to the service. * @param {string} params.accountId - The IBM Cloud account ID. * @param {string} params.destinationId - The ID of the destination. * @param {TestDestinationRequestBodyPrototype} params.testDestinationRequestBodyPrototype - * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<PlatformNotificationsV1.Response<PlatformNotificationsV1.TestDestinationResponseBody>>} */ PlatformNotificationsV1.prototype.testDistributionListDestination = function (params) { var _params = __assign({}, params); var _requiredParams = ['accountId', 'destinationId', 'testDestinationRequestBodyPrototype']; var _validParams = [ 'accountId', 'destinationId', 'testDestinationRequestBodyPrototype', 'signal', 'headers', ]; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = _params.testDestinationRequestBodyPrototype; var path = { 'account_id': _params.accountId, 'destination_id': _params.destinationId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(PlatformNotificationsV1.DEFAULT_SERVICE_NAME, 'v1', 'testDistributionListDestination'); var parameters = { options: { url: '/v1/distribution_lists/{account_id}/destinations/{destination_id}/test', method: 'POST', body: body, path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, { 'Accept': 'application/json', 'Content-Type': 'application/json', }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /************************* * userPreferences ************************/ /** * Get all communication preferences. * * Retrieve all communication preferences of a user in an account. * * @param {Object} params - The parameters to send to the service. * @param {string} params.iamId - The IAM ID of the user. Must match the IAM ID in the bearer token. * @param {string} [params.accountId] - The IBM Cloud account ID. If not provided, the account ID from the bearer * token will be used. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<PlatformNotificationsV1.Response<PlatformNotificationsV1.PreferencesObject>>} */ PlatformNotificationsV1.prototype.getPreferences = function (params) { var _params = __assign({}, params); var _requiredParams = ['iamId']; var _validParams = ['iamId', '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 path = { 'iam_id': _params.iamId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(PlatformNotificationsV1.DEFAULT_SERVICE_NAME, 'v1', 'getPreferences'); var parameters = { options: { url: '/v1/notifications/{iam_id}/preferences', 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); }; /** * Create communication preferences. * * Create communication preferences for the specified account. * * @param {Object} params - The parameters to send to the service. * @param {string} params.iamId - The IAM ID of the user. Must match the IAM ID in the bearer token. * @param {PreferenceValueWithUpdates} [params.incidentSeverity1] - Preference settings for notification types that * support updates. * @param {PreferenceValueWithUpdates} [params.incidentSeverity2] - Preference settings for notification types that * support updates. * @param {PreferenceValueWithUpdates} [params.incidentSeverity3] - Preference settings for notification types that * support updates. * @param {PreferenceValueWithUpdates} [params.incidentSeverity4] - Preference settings for notification types that * support updates. * @param {PreferenceValueWithUpdates} [params.maintenanceHigh] - Preference settings for notification types that * support updates. * @param {PreferenceValueWithUpdates} [params.maintenanceMedium] - Preference settings for notification types that * support updates. * @param {PreferenceValueWithUpdates} [params.maintenanceLow] - Preference settings for notification types that * support updates. * @param {PreferenceValueWithoutUpdates} [params.announcementsMajor] - Preference settings for notification types * that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.announcementsMinor] - Preference settings for notification types * that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.securityNormal] - Preference settings for notification types that do * not support updates. * @param {PreferenceValueWithoutUpdates} [params.accountNormal] - Preference settings for notification types that do * not support updates. * @param {PreferenceValueWithoutUpdates} [params.billingAndUsageOrder] - Preference settings for notification types * that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.billingAndUsageInvoices] - Preference settings for notification * types that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.billingAndUsagePayments] - Preference settings for notification * types that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.billingAndUsageSubscriptionsAndPromoCodes] - Preference settings for * notification types that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.billingAndUsageSpendingAlerts] - Preference settings for * notification types that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.resourceactivityNormal] - Preference settings for notification types * that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.orderingReview] - Preference settings for notification types that do * not support updates. * @param {PreferenceValueWithoutUpdates} [params.orderingApproved] - Preference settings for notification types that * do not support updates. * @param {PreferenceValueWithoutUpdates} [params.orderingApprovedVsi] - Preference settings for notification types * that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.orderingApprovedServer] - Preference settings for notification types * that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.provisioningReloadComplete] - Preference settings for notification * types that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.provisioningCompleteVsi] - Preference settings for notification * types that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.provisioningCompleteServer] - Preference settings for notification * types that do not support updates. * @param {string} [params.accountId] - The IBM Cloud account ID. If not provided, the account ID from the bearer * token will be used. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<PlatformNotificationsV1.Response<PlatformNotificationsV1.PreferencesObject>>} */ PlatformNotificationsV1.prototype.createPreferences = function (params) { var _params = __assign({}, params); var _requiredParams = ['iamId']; var _validParams = [ 'iamId', 'incidentSeverity1', 'incidentSeverity2', 'incidentSeverity3', 'incidentSeverity4', 'maintenanceHigh', 'maintenanceMedium', 'maintenanceLow', 'announcementsMajor', 'announcementsMinor', 'securityNormal', 'accountNormal', 'billingAndUsageOrder', 'billingAndUsageInvoices', 'billingAndUsagePayments', 'billingAndUsageSubscriptionsAndPromoCodes', 'billingAndUsageSpendingAlerts', 'resourceactivityNormal', 'orderingReview', 'orderingApproved', 'orderingApprovedVsi', 'orderingApprovedServer', 'provisioningReloadComplete', 'provisioningCompleteVsi', 'provisioningCompleteServer', 'accountId', 'signal', 'headers', ]; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = { 'incident_severity1': _params.incidentSeverity1, 'incident_severity2': _params.incidentSeverity2, 'incident_severity3': _params.incidentSeverity3, 'incident_severity4': _params.incidentSeverity4, 'maintenance_high': _params.maintenanceHigh, 'maintenance_medium': _params.maintenanceMedium, 'maintenance_low': _params.maintenanceLow, 'announcements_major': _params.announcementsMajor, 'announcements_minor': _params.announcementsMinor, 'security_normal': _params.securityNormal, 'account_normal': _params.accountNormal, 'billing_and_usage_order': _params.billingAndUsageOrder, 'billing_and_usage_invoices': _params.billingAndUsageInvoices, 'billing_and_usage_payments': _params.billingAndUsagePayments, 'billing_and_usage_subscriptions_and_promo_codes': _params.billingAndUsageSubscriptionsAndPromoCodes, 'billing_and_usage_spending_alerts': _params.billingAndUsageSpendingAlerts, 'resourceactivity_normal': _params.resourceactivityNormal, 'ordering_review': _params.orderingReview, 'ordering_approved': _params.orderingApproved, 'ordering_approved_vsi': _params.orderingApprovedVsi, 'ordering_approved_server': _params.orderingApprovedServer, 'provisioning_reload_complete': _params.provisioningReloadComplete, 'provisioning_complete_vsi': _params.provisioningCompleteVsi, 'provisioning_complete_server': _params.provisioningCompleteServer, }; var query = { 'account_id': _params.accountId, }; var path = { 'iam_id': _params.iamId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(PlatformNotificationsV1.DEFAULT_SERVICE_NAME, 'v1', 'createPreferences'); var parameters = { options: { url: '/v1/notifications/{iam_id}/preferences', method: 'POST', 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', }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Update communication preferences. * * Update communication preferences for the specified account. * * @param {Object} params - The parameters to send to the service. * @param {string} params.iamId - The IAM ID of the user. Must match the IAM ID in the bearer token. * @param {PreferenceValueWithUpdates} [params.incidentSeverity1] - Preference settings for notification types that * support updates. * @param {PreferenceValueWithUpdates} [params.incidentSeverity2] - Preference settings for notification types that * support updates. * @param {PreferenceValueWithUpdates} [params.incidentSeverity3] - Preference settings for notification types that * support updates. * @param {PreferenceValueWithUpdates} [params.incidentSeverity4] - Preference settings for notification types that * support updates. * @param {PreferenceValueWithUpdates} [params.maintenanceHigh] - Preference settings for notification types that * support updates. * @param {PreferenceValueWithUpdates} [params.maintenanceMedium] - Preference settings for notification types that * support updates. * @param {PreferenceValueWithUpdates} [params.maintenanceLow] - Preference settings for notification types that * support updates. * @param {PreferenceValueWithoutUpdates} [params.announcementsMajor] - Preference settings for notification types * that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.announcementsMinor] - Preference settings for notification types * that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.securityNormal] - Preference settings for notification types that do * not support updates. * @param {PreferenceValueWithoutUpdates} [params.accountNormal] - Preference settings for notification types that do * not support updates. * @param {PreferenceValueWithoutUpdates} [params.billingAndUsageOrder] - Preference settings for notification types * that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.billingAndUsageInvoices] - Preference settings for notification * types that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.billingAndUsagePayments] - Preference settings for notification * types that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.billingAndUsageSubscriptionsAndPromoCodes] - Preference settings for * notification types that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.billingAndUsageSpendingAlerts] - Preference settings for * notification types that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.resourceactivityNormal] - Preference settings for notification types * that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.orderingReview] - Preference settings for notification types that do * not support updates. * @param {PreferenceValueWithoutUpdates} [params.orderingApproved] - Preference settings for notification types that * do not support updates. * @param {PreferenceValueWithoutUpdates} [params.orderingApprovedVsi] - Preference settings for notification types * that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.orderingApprovedServer] - Preference settings for notification types * that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.provisioningReloadComplete] - Preference settings for notification * types that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.provisioningCompleteVsi] - Preference settings for notification * types that do not support updates. * @param {PreferenceValueWithoutUpdates} [params.provisioningCompleteServer] - Preference settings for notification * types that do not support updates. * @param {string} [params.accountId] - The IBM Cloud account ID. If not provided, the account ID from the bearer * token will be used. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<PlatformNotificationsV1.Response<PlatformNotificationsV1.PreferencesObject>>} */ PlatformNotificationsV1.prototype.replaceNotificationPreferences = function (params) { var _params = __assign({}, params); var _requiredParams = ['iamId']; var _validParams = [ 'iamId', 'incidentSeverity1', 'incidentSeverity2', 'incidentSeverity3', 'incidentSeverity4', 'maintenanceHigh', 'maintenanceMedium', 'maintenanceLow', 'announcementsMajor', 'announcementsMinor', 'securityNormal', 'accountNormal', 'billingAndUsageOrder', 'billingAndUsageInvoices', 'billingAndUsagePayments', 'billingAndUsageSubscriptionsAndPromoCodes', 'billingAndUsageSpendingAlerts', 'resourceactivityNormal', 'orderingReview', 'orderingApproved', 'orderingApprovedVsi', 'orderingApprovedServer', 'provisioningReloadComplete', 'provisioningCompleteVsi', 'provisioningCompleteServer', 'accountId', 'signal', 'headers', ]; var _validationErrors = (0, ibm_cloud_sdk_core_1.validateParams)(_params, _requiredParams, _validParams); if (_validationErrors) { return Promise.reject(_validationErrors); } var body = { 'incident_severity1': _params.incidentSeverity1, 'incident_severity2': _params.incidentSeverity2, 'incident_severity3': _params.incidentSeverity3, 'incident_severity4': _params.incidentSeverity4, 'maintenance_high': _params.maintenanceHigh, 'maintenance_medium': _params.maintenanceMedium, 'maintenance_low': _params.maintenanceLow, 'announcements_major': _params.announcementsMajor, 'announcements_minor': _params.announcementsMinor, 'security_normal': _params.securityNormal, 'account_normal': _params.accountNormal, 'billing_and_usage_order': _params.billingAndUsageOrder, 'billing_and_usage_invoices': _params.billingAndUsageInvoices, 'billing_and_usage_payments': _params.billingAndUsagePayments, 'billing_and_usage_subscriptions_and_promo_codes': _params.billingAndUsageSubscriptionsAndPromoCodes, 'billing_and_usage_spending_alerts': _params.billingAndUsageSpendingAlerts, 'resourceactivity_normal': _params.resourceactivityNormal, 'ordering_review': _params.orderingReview, 'ordering_approved': _params.orderingApproved, 'ordering_approved_vsi': _params.orderingApprovedVsi, 'ordering_approved_server': _params.orderingApprovedServer, 'provisioning_reload_complete': _params.provisioningReloadComplete, 'provisioning_complete_vsi': _params.provisioningCompleteVsi, 'provisioning_complete_server': _params.provisioningCompleteServer, }; var query = { 'account_id': _params.accountId, }; var path = { 'iam_id': _params.iamId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(PlatformNotificationsV1.DEFAULT_SERVICE_NAME, 'v1', 'replaceNotificationPreferences'); var parameters = { options: { url: '/v1/notifications/{iam_id}/preferences', 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', }, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; /** * Reset all preferences to their default values. * * Delete all communication preferences for the specified account, and reset all preferences to their default values. * * @param {Object} params - The parameters to send to the service. * @param {string} params.iamId - The IAM ID of the user. Must match the IAM ID in the bearer token. * @param {string} [params.accountId] - The IBM Cloud account ID. If not provided, the account ID from the bearer * token will be used. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<PlatformNotificationsV1.Response<PlatformNotificationsV1.EmptyObject>>} */ PlatformNotificationsV1.prototype.deleteNotificationPreferences = function (params) { var _params = __assign({}, params); var _requiredParams = ['iamId']; var _validParams = ['iamId', '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 path = { 'iam_id': _params.iamId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(PlatformNotificationsV1.DEFAULT_SERVICE_NAME, 'v1', 'deleteNotificationPreferences'); var parameters = { options: { url: '/v1/notifications/{iam_id}/preferences', method: 'DELETE', qs: query, path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, this.baseOptions.headers, {}, _params.headers), axiosOptions: { signal: _params.signal, }, }), }; return this.createRequest(parameters); }; PlatformNotificationsV1.DEFAULT_SERVICE_URL = 'https://notifications.cloud.ibm.com/api'; PlatformNotificationsV1.DEFAULT_SERVICE_NAME = 'platform_notifications'; return PlatformNotificationsV1; }(ibm_cloud_sdk_core_1.BaseService)); /************************* * interfaces ************************/ (function (PlatformNotificationsV1) { var Notification; (function (Notification) { var Constants; (function (Constants) { /** The category of the notification. */ var Category; (function (Category) { Category["INCIDENT"] = "incident"; Category["MAINTENANCE"] = "maintenance"; Category["ANNOUNCEMENTS"] = "announcements"; Category["SECURITY_BULLETINS"] = "security_bulletins"; Category["SECURITY"] = "security"; Category["RESOURCE"] = "resource"; Category["BILLING_AND_USAGE"] = "billing_and_usage"; Category["ORDERING"] = "ordering"; Category["PROVISIONING"] = "provisioning"; Category["ACCOUNT"] = "account"; })(Category = Constants.Category || (Constants.Category = {})); /** The current state of the notification. */ var State; (function (State) { State["NEW"] = "new"; State["IN_PROGRESS"] = "in-progress"; State["COMPLETE"] = "complete"; State["RESOLVED"] = "resolved"; })(State = Constants.State || (Constants.State = {})); /** The completion code of the notification. */ var CompletionCode; (function (CompletionCode) { CompletionCode["SUCCESSFUL"] = "successful"; CompletionCode["FAILED"] = "failed"; CompletionCode["CANCELLED"] = "cancelled"; })(CompletionCode = Constants.CompletionCode || (Constants.CompletionCode = {})); })(Constants = Notification.Constants || (Notification.Constants = {})); })(Notification = PlatformNotificationsV1.Notification || (PlatformNotificationsV1.Notification = {})); var PreferenceValueWithUpdates; (function (PreferenceValueWithUpdates) { var Constants; (function (Constants) { /** Array of communication channels for this preference. */ var Channels; (function (Channels) { Channels["EMAIL"] = "email"; })(Channels = Constants.Channels || (Constants.Channels = {})); })(Constants = PreferenceValueWithUpdates.Constants || (PreferenceValueWithUpdates.Constants = {})); })(PreferenceValueWithUpdates = PlatformNotificationsV1.PreferenceValueWithUpdates || (PlatformNotificationsV1.PreferenceValueWithUpdates = {})); var PreferenceValueWithoutUpdates; (function (PreferenceValueWithoutUpdates) { var Constants; (function (Constants) { /** Array of communication channels for this preference. */ var Channels; (function (Channels) { Channels["EMAIL"] = "email"; })(Channels = Constants.Channels || (Constants.Channels = {})); })(Constants = PreferenceValueWithoutUpdates.Constants || (PreferenceValueWithoutUpdates.Constants = {})); })(PreferenceValueWithoutUpdates = PlatformNotificationsV1.PreferenceValueWithoutUpdates || (PlatformNotificationsV1.PreferenceValueWithoutUpdates = {})); var AddDestinationPrototypeEventNotificationDestinationPrototype; (function (AddDestinationPrototypeEventNotificationDestinationPrototype) { var Constants; (function (Constants) { /** The type of the destination. */ var DestinationType; (function (DestinationType) { DestinationType["EVENT_NOTIFICATIONS"] = "event_notifications"; })(DestinationType = Constants.DestinationType || (Constants.DestinationType = {})); })(Constants = AddDestinationPrototypeEventNotificationDestinationPrototype.Constants || (AddDestinationPrototypeEventNotificationDestinationPrototype.Constants = {})); })(AddDestinationPrototypeEventNotificationDestinationPrototype = PlatformNotificationsV1.AddDestinationPrototypeEventNotificationDestinationPrototype || (PlatformNotificationsV1.AddDestinationPrototypeEventNotificationDestinationPrototype = {})); var AddDestinationEventNotificationDestination; (function (AddDestinationEventNotificationDestination) { var Constants; (function (Constants) { /** The type of the destination. */ var DestinationType; (function (DestinationType) { DestinationType["EVENT_NOTIFICATIONS"] = "event_notifications"; })(DestinationType = Constants.DestinationType || (Constants.DestinationType = {})); })(Constants = AddDestinationEventNotificationDestination.Constants || (AddDestinationEventNotificationDestination.Constants = {})); })(AddDestinationEventNotificationDestination = PlatformNotificationsV1.AddDestinationEventNotificationDestination || (PlatformNotificationsV1.AddDestinationEventNotificationDestination = {})); var TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype; (function (TestDestinationRequestBodyPrototypeTestEventNotificationDestinationRequestBodyPrototype) { var Constants; (function (Constants) { /** The type of the destination. */ var DestinationType; (function (DestinationType) { DestinationType["EVENT_NOTIFICATIONS"] = "even