@ibm-cloud/platform-services
Version:
Node.js client library for IBM Cloud Platform Services
152 lines • 6.31 kB
JavaScript
;
/**
* (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);
};
/**
* IBM OpenAPI SDK Code Generator Version: 3.111.0-1bfb72c2-20260206-185521
*/
var extend = require("extend");
var ibm_cloud_sdk_core_1 = require("ibm-cloud-sdk-core");
var common_1 = require("../lib/common");
/**
* The Account Management API allows for the management of Account
*
* API Version: 4.0.0
*/
var AccountManagementV4 = /** @class */ (function (_super) {
__extends(AccountManagementV4, _super);
/**
* Construct a AccountManagementV4 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 {AccountManagementV4}
*/
function AccountManagementV4(options) {
var _this = this;
options = options || {};
_this = _super.call(this, options) || this;
if (options.serviceUrl) {
_this.setServiceUrl(options.serviceUrl);
}
else {
_this.setServiceUrl(AccountManagementV4.DEFAULT_SERVICE_URL);
}
return _this;
}
/*************************
* Factory method
************************/
/**
* Constructs an instance of AccountManagementV4 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 {AccountManagementV4}
*/
AccountManagementV4.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 AccountManagementV4(options);
service.configureService(options.serviceName);
if (options.serviceUrl) {
service.setServiceUrl(options.serviceUrl);
}
return service;
};
/*************************
* default
************************/
/**
* Get Account by Account ID.
*
* Returns the details of an account.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.accountId - The unique identifier of the account you want to retrieve.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<AccountManagementV4.Response<AccountManagementV4.AccountResponse>>}
*/
AccountManagementV4.prototype.getAccount = 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)(AccountManagementV4.DEFAULT_SERVICE_NAME, 'v4', 'getAccount');
var parameters = {
options: {
url: '/v4/accounts/{account_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);
};
AccountManagementV4.DEFAULT_SERVICE_URL = 'https://accounts.test.cloud.ibm.com';
AccountManagementV4.DEFAULT_SERVICE_NAME = 'account_management';
return AccountManagementV4;
}(ibm_cloud_sdk_core_1.BaseService));
module.exports = AccountManagementV4;
//# sourceMappingURL=v4.js.map