|
| 1 | +/** |
| 2 | + * (C) Copyright IBM Corp. 2026. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +/** |
| 18 | + * IBM OpenAPI SDK Code Generator Version: 3.111.0-1bfb72c2-20260206-185521 |
| 19 | + */ |
| 20 | + |
| 21 | +import * as extend from 'extend'; |
| 22 | +import { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http'; |
| 23 | +import { |
| 24 | + AbortSignal, |
| 25 | + Authenticator, |
| 26 | + BaseService, |
| 27 | + UserOptions, |
| 28 | + getAuthenticatorFromEnvironment, |
| 29 | + validateParams, |
| 30 | +} from 'ibm-cloud-sdk-core'; |
| 31 | +import { getSdkHeaders } from '../lib/common'; |
| 32 | + |
| 33 | +/** |
| 34 | + * The Account Management API allows for the management of Account |
| 35 | + * |
| 36 | + * API Version: 4.0.0 |
| 37 | + */ |
| 38 | + |
| 39 | +class AccountManagementV4 extends BaseService { |
| 40 | + static DEFAULT_SERVICE_URL: string = 'https://accounts.test.cloud.ibm.com'; |
| 41 | + |
| 42 | + static DEFAULT_SERVICE_NAME: string = 'account_management'; |
| 43 | + |
| 44 | + /************************* |
| 45 | + * Factory method |
| 46 | + ************************/ |
| 47 | + |
| 48 | + /** |
| 49 | + * Constructs an instance of AccountManagementV4 with passed in options and external configuration. |
| 50 | + * |
| 51 | + * @param {UserOptions} [options] - The parameters to send to the service. |
| 52 | + * @param {string} [options.serviceName] - The name of the service to configure |
| 53 | + * @param {Authenticator} [options.authenticator] - The Authenticator object used to authenticate requests to the service |
| 54 | + * @param {string} [options.serviceUrl] - The base URL for the service |
| 55 | + * @returns {AccountManagementV4} |
| 56 | + */ |
| 57 | + |
| 58 | + public static newInstance(options: UserOptions): AccountManagementV4 { |
| 59 | + options = options || {}; |
| 60 | + |
| 61 | + if (!options.serviceName) { |
| 62 | + options.serviceName = this.DEFAULT_SERVICE_NAME; |
| 63 | + } |
| 64 | + if (!options.authenticator) { |
| 65 | + options.authenticator = getAuthenticatorFromEnvironment(options.serviceName); |
| 66 | + } |
| 67 | + const service = new AccountManagementV4(options); |
| 68 | + service.configureService(options.serviceName); |
| 69 | + if (options.serviceUrl) { |
| 70 | + service.setServiceUrl(options.serviceUrl); |
| 71 | + } |
| 72 | + return service; |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * Construct a AccountManagementV4 object. |
| 77 | + * |
| 78 | + * @param {Object} options - Options for the service. |
| 79 | + * @param {string} [options.serviceUrl] - The base URL for the service |
| 80 | + * @param {OutgoingHttpHeaders} [options.headers] - Default headers that shall be included with every request to the service. |
| 81 | + * @param {Authenticator} options.authenticator - The Authenticator object used to authenticate requests to the service |
| 82 | + * @constructor |
| 83 | + * @returns {AccountManagementV4} |
| 84 | + */ |
| 85 | + constructor(options: UserOptions) { |
| 86 | + options = options || {}; |
| 87 | + |
| 88 | + super(options); |
| 89 | + if (options.serviceUrl) { |
| 90 | + this.setServiceUrl(options.serviceUrl); |
| 91 | + } else { |
| 92 | + this.setServiceUrl(AccountManagementV4.DEFAULT_SERVICE_URL); |
| 93 | + } |
| 94 | + } |
| 95 | + |
| 96 | + /************************* |
| 97 | + * default |
| 98 | + ************************/ |
| 99 | + |
| 100 | + /** |
| 101 | + * Get Account by Account ID. |
| 102 | + * |
| 103 | + * Returns the details of an account. |
| 104 | + * |
| 105 | + * @param {Object} params - The parameters to send to the service. |
| 106 | + * @param {string} params.accountId - The unique identifier of the account you want to retrieve. |
| 107 | + * @param {OutgoingHttpHeaders} [params.headers] - Custom request headers |
| 108 | + * @returns {Promise<AccountManagementV4.Response<AccountManagementV4.AccountResponse>>} |
| 109 | + */ |
| 110 | + public getAccount( |
| 111 | + params: AccountManagementV4.GetAccountParams |
| 112 | + ): Promise<AccountManagementV4.Response<AccountManagementV4.AccountResponse>> { |
| 113 | + const _params = { ...params }; |
| 114 | + const _requiredParams = ['accountId']; |
| 115 | + const _validParams = ['accountId', 'signal', 'headers']; |
| 116 | + const _validationErrors = validateParams(_params, _requiredParams, _validParams); |
| 117 | + if (_validationErrors) { |
| 118 | + return Promise.reject(_validationErrors); |
| 119 | + } |
| 120 | + |
| 121 | + const path = { |
| 122 | + 'account_id': _params.accountId, |
| 123 | + }; |
| 124 | + |
| 125 | + const sdkHeaders = getSdkHeaders(AccountManagementV4.DEFAULT_SERVICE_NAME, 'v4', 'getAccount'); |
| 126 | + |
| 127 | + const parameters = { |
| 128 | + options: { |
| 129 | + url: '/v4/accounts/{account_id}', |
| 130 | + method: 'GET', |
| 131 | + path, |
| 132 | + }, |
| 133 | + defaultOptions: extend(true, {}, this.baseOptions, { |
| 134 | + headers: extend( |
| 135 | + true, |
| 136 | + sdkHeaders, |
| 137 | + this.baseOptions.headers, |
| 138 | + { |
| 139 | + 'Accept': 'application/json', |
| 140 | + }, |
| 141 | + _params.headers |
| 142 | + ), |
| 143 | + axiosOptions: { |
| 144 | + signal: _params.signal, |
| 145 | + }, |
| 146 | + }), |
| 147 | + }; |
| 148 | + |
| 149 | + return this.createRequest(parameters); |
| 150 | + } |
| 151 | +} |
| 152 | + |
| 153 | +/************************* |
| 154 | + * interfaces |
| 155 | + ************************/ |
| 156 | + |
| 157 | +namespace AccountManagementV4 { |
| 158 | + /** An operation response. */ |
| 159 | + export interface Response<T = any> { |
| 160 | + result: T; |
| 161 | + status: number; |
| 162 | + statusText: string; |
| 163 | + headers: IncomingHttpHeaders; |
| 164 | + } |
| 165 | + |
| 166 | + /** The callback for a service request. */ |
| 167 | + export type Callback<T> = (error: any, response?: Response<T>) => void; |
| 168 | + |
| 169 | + /** The body of a service request that returns no response data. */ |
| 170 | + export interface EmptyObject {} |
| 171 | + |
| 172 | + /** A standard JS object, defined to avoid the limitations of `Object` and `object` */ |
| 173 | + export interface JsonObject { |
| 174 | + [key: string]: any; |
| 175 | + } |
| 176 | + |
| 177 | + /************************* |
| 178 | + * request interfaces |
| 179 | + ************************/ |
| 180 | + |
| 181 | + interface DefaultParams { |
| 182 | + headers?: OutgoingHttpHeaders; |
| 183 | + signal?: AbortSignal; |
| 184 | + } |
| 185 | + |
| 186 | + /** Parameters for the `getAccount` operation. */ |
| 187 | + export interface GetAccountParams extends DefaultParams { |
| 188 | + /** The unique identifier of the account you want to retrieve. */ |
| 189 | + accountId: string; |
| 190 | + } |
| 191 | + |
| 192 | + /************************* |
| 193 | + * model interfaces |
| 194 | + ************************/ |
| 195 | + |
| 196 | + /** |
| 197 | + * AccountResponseTraits. |
| 198 | + */ |
| 199 | + export interface AccountResponseTraits { |
| 200 | + eu_supported: boolean; |
| 201 | + poc: boolean; |
| 202 | + hippa: boolean; |
| 203 | + } |
| 204 | + |
| 205 | + /** |
| 206 | + * AccountResponse. |
| 207 | + */ |
| 208 | + export interface AccountResponse { |
| 209 | + name: string; |
| 210 | + id: string; |
| 211 | + owner: string; |
| 212 | + owner_userid: string; |
| 213 | + owner_iamid: string; |
| 214 | + type: string; |
| 215 | + status: string; |
| 216 | + linked_softlayer_account: string; |
| 217 | + team_directory_enabled: boolean; |
| 218 | + traits: AccountResponseTraits; |
| 219 | + } |
| 220 | +} |
| 221 | + |
| 222 | +export = AccountManagementV4; |
0 commit comments