UNPKG

@ibm-cloud/platform-services

Version:

Node.js client library for IBM Cloud Platform Services

207 lines 9.61 kB
"use strict"; /** * (C) Copyright IBM Corp. 2021. * * 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.33.0-caf29bd0-20210603-225214 */ var extend = require("extend"); var ibm_cloud_sdk_core_1 = require("ibm-cloud-sdk-core"); var common_1 = require("../lib/common"); /** * API docs for IBM Cloud Shell repository */ var IbmCloudShellV1 = /** @class */ (function (_super) { __extends(IbmCloudShellV1, _super); /** * Construct a IbmCloudShellV1 object. * * @param {Object} options - Options for the service. * @param {string} [options.serviceUrl] - The base url to use when contacting the service. The base url may differ between IBM Cloud regions. * @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 {IbmCloudShellV1} */ function IbmCloudShellV1(options) { var _this = this; options = options || {}; _this = _super.call(this, options) || this; if (options.serviceUrl) { _this.setServiceUrl(options.serviceUrl); } else { _this.setServiceUrl(IbmCloudShellV1.DEFAULT_SERVICE_URL); } return _this; } /************************* * Factory method ************************/ /** * Constructs an instance of IbmCloudShellV1 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 URL for the service * @returns {IbmCloudShellV1} */ IbmCloudShellV1.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 IbmCloudShellV1(options); service.configureService(options.serviceName); if (options.serviceUrl) { service.setServiceUrl(options.serviceUrl); } return service; }; /************************* * accountSettings ************************/ /** * Get account settings. * * Retrieve account settings for the given account ID. Call this method to get details about a particular account * setting, whether Cloud Shell is enabled, the list of enabled regions and the list of enabled features. Users need * to be an account owner or users need to be assigned an IAM policy with the Administrator role for the Cloud Shell * account management service. * * @param {Object} params - The parameters to send to the service. * @param {string} params.accountId - The account ID in which the account settings belong to. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<IbmCloudShellV1.Response<IbmCloudShellV1.AccountSettings>>} */ IbmCloudShellV1.prototype.getAccountSettings = function (params) { var _params = __assign({}, params); var requiredParams = ['accountId']; var missingParams = (0, ibm_cloud_sdk_core_1.getMissingParams)(_params, requiredParams); if (missingParams) { return Promise.reject(missingParams); } var path = { 'account_id': _params.accountId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(IbmCloudShellV1.DEFAULT_SERVICE_NAME, 'v1', 'getAccountSettings'); var parameters = { options: { url: '/api/v1/user/accounts/{account_id}/settings', method: 'GET', path: path, }, defaultOptions: extend(true, {}, this.baseOptions, { headers: extend(true, sdkHeaders, { 'Accept': 'application/json', }, _params.headers), }), }; return this.createRequest(parameters); }; /** * Update account settings. * * Update account settings for the given account ID. Call this method to update account settings configuration, you * can enable or disable Cloud Shell, enable or disable available regions and enable and disable features. To update * account settings, users need to be an account owner or users need to be assigned an IAM policy with the * Administrator role for the Cloud Shell account management service. * * @param {Object} params - The parameters to send to the service. * @param {string} params.accountId - The account ID in which the account settings belong to. * @param {string} [params.rev] - Unique revision number for the settings object. * @param {boolean} [params.defaultEnableNewFeatures] - You can choose which Cloud Shell features are available in the * account and whether any new features are enabled as they become available. The feature settings apply only to the * enabled Cloud Shell locations. * @param {boolean} [params.defaultEnableNewRegions] - Set whether Cloud Shell is enabled in a specific location for * the account. The location determines where user and session data are stored. By default, users are routed to the * nearest available location. * @param {boolean} [params.enabled] - When enabled, Cloud Shell is available to all users in the account. * @param {Feature[]} [params.features] - List of Cloud Shell features. * @param {RegionSetting[]} [params.regions] - List of Cloud Shell region settings. * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers * @returns {Promise<IbmCloudShellV1.Response<IbmCloudShellV1.AccountSettings>>} */ IbmCloudShellV1.prototype.updateAccountSettings = function (params) { var _params = __assign({}, params); var requiredParams = ['accountId']; var missingParams = (0, ibm_cloud_sdk_core_1.getMissingParams)(_params, requiredParams); if (missingParams) { return Promise.reject(missingParams); } var body = { '_rev': _params.rev, 'default_enable_new_features': _params.defaultEnableNewFeatures, 'default_enable_new_regions': _params.defaultEnableNewRegions, 'enabled': _params.enabled, 'features': _params.features, 'regions': _params.regions, }; var path = { 'account_id': _params.accountId, }; var sdkHeaders = (0, common_1.getSdkHeaders)(IbmCloudShellV1.DEFAULT_SERVICE_NAME, 'v1', 'updateAccountSettings'); var parameters = { options: { url: '/api/v1/user/accounts/{account_id}/settings', method: 'POST', 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); }; IbmCloudShellV1.DEFAULT_SERVICE_URL = 'https://api.shell.cloud.ibm.com'; IbmCloudShellV1.DEFAULT_SERVICE_NAME = 'ibm_cloud_shell'; return IbmCloudShellV1; }(ibm_cloud_sdk_core_1.BaseService)); module.exports = IbmCloudShellV1; //# sourceMappingURL=v1.js.map