@ibm-cloud/platform-services
Version:
Node.js client library for IBM Cloud Platform Services
388 lines (387 loc) • 18 kB
TypeScript
/**
* (C) Copyright IBM Corp. 2023.
*
* 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.
*/
/// <reference types="node" />
import { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http';
import { BaseService, UserOptions } from 'ibm-cloud-sdk-core';
/**
* Billing units for IBM Cloud Enterprise
*
* API Version: 1.0.0
*/
declare class EnterpriseBillingUnitsV1 extends BaseService {
static DEFAULT_SERVICE_URL: string;
static DEFAULT_SERVICE_NAME: string;
/*************************
* Factory method
************************/
/**
* Constructs an instance of EnterpriseBillingUnitsV1 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 {EnterpriseBillingUnitsV1}
*/
static newInstance(options: UserOptions): EnterpriseBillingUnitsV1;
/**
* Construct a EnterpriseBillingUnitsV1 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 {EnterpriseBillingUnitsV1}
*/
constructor(options: UserOptions);
/*************************
* billingUnits
************************/
/**
* Get billing unit by ID.
*
* Return the billing unit information if it exists.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.billingUnitId - The ID of the requested billing unit.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<EnterpriseBillingUnitsV1.Response<EnterpriseBillingUnitsV1.BillingUnit>>}
*/
getBillingUnit(params: EnterpriseBillingUnitsV1.GetBillingUnitParams): Promise<EnterpriseBillingUnitsV1.Response<EnterpriseBillingUnitsV1.BillingUnit>>;
/**
* List billing units.
*
* Return matching billing unit information if any exists. Omits internal properties and enterprise account ID from
* the billing unit.
*
* @param {Object} [params] - The parameters to send to the service.
* @param {string} [params.accountId] - The enterprise account ID.
* @param {string} [params.enterpriseId] - The enterprise ID.
* @param {string} [params.accountGroupId] - The account group ID.
* @param {number} [params.limit] - Return results up to this limit. Valid values are between 0 and 100.
* @param {string} [params.start] - The pagination offset. This represents the index of the first returned result.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<EnterpriseBillingUnitsV1.Response<EnterpriseBillingUnitsV1.BillingUnitsList>>}
*/
listBillingUnits(params?: EnterpriseBillingUnitsV1.ListBillingUnitsParams): Promise<EnterpriseBillingUnitsV1.Response<EnterpriseBillingUnitsV1.BillingUnitsList>>;
/*************************
* billingOptions
************************/
/**
* List billing options.
*
* Return matching billing options if any exist. Show subscriptions and promotional offers that are available to a
* billing unit.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.billingUnitId - The billing unit ID.
* @param {number} [params.limit] - Return results up to this limit. Valid values are between 0 and 100.
* @param {string} [params.start] - The pagination offset. This represents the index of the first returned result.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<EnterpriseBillingUnitsV1.Response<EnterpriseBillingUnitsV1.BillingOptionsList>>}
*/
listBillingOptions(params: EnterpriseBillingUnitsV1.ListBillingOptionsParams): Promise<EnterpriseBillingUnitsV1.Response<EnterpriseBillingUnitsV1.BillingOptionsList>>;
/*************************
* creditPools
************************/
/**
* Get credit pools.
*
* Get credit pools for a billing unit. Credit pools can be either platform or support credit pools. The platform
* credit pool contains credit from platform subscriptions and promotional offers. The support credit pool contains
* credit from support subscriptions.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.billingUnitId - The ID of the billing unit.
* @param {string} [params.date] - The date in the format of YYYY-MM.
* @param {string} [params.type] - Filters the credit pool by type, either `PLATFORM` or `SUPPORT`.
* @param {number} [params.limit] - Return results up to this limit. Valid values are between 0 and 100.
* @param {string} [params.start] - The pagination offset. This represents the index of the first returned result.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<EnterpriseBillingUnitsV1.Response<EnterpriseBillingUnitsV1.CreditPoolsList>>}
*/
getCreditPools(params: EnterpriseBillingUnitsV1.GetCreditPoolsParams): Promise<EnterpriseBillingUnitsV1.Response<EnterpriseBillingUnitsV1.CreditPoolsList>>;
}
/*************************
* interfaces
************************/
declare namespace EnterpriseBillingUnitsV1 {
/** An operation response. */
interface Response<T = any> {
result: T;
status: number;
statusText: string;
headers: IncomingHttpHeaders;
}
/** The callback for a service request. */
type Callback<T> = (error: any, response?: Response<T>) => void;
/** The body of a service request that returns no response data. */
interface EmptyObject {
}
/** A standard JS object, defined to avoid the limitations of `Object` and `object` */
interface JsonObject {
[]: any;
}
/*************************
* request interfaces
************************/
/** Parameters for the `getBillingUnit` operation. */
interface GetBillingUnitParams {
/** The ID of the requested billing unit. */
billingUnitId: string;
headers?: OutgoingHttpHeaders;
}
/** Parameters for the `listBillingUnits` operation. */
interface ListBillingUnitsParams {
/** The enterprise account ID. */
accountId?: string;
/** The enterprise ID. */
enterpriseId?: string;
/** The account group ID. */
accountGroupId?: string;
/** Return results up to this limit. Valid values are between 0 and 100. */
limit?: number;
/** The pagination offset. This represents the index of the first returned result. */
start?: string;
headers?: OutgoingHttpHeaders;
}
/** Parameters for the `listBillingOptions` operation. */
interface ListBillingOptionsParams {
/** The billing unit ID. */
billingUnitId: string;
/** Return results up to this limit. Valid values are between 0 and 100. */
limit?: number;
/** The pagination offset. This represents the index of the first returned result. */
start?: string;
headers?: OutgoingHttpHeaders;
}
/** Parameters for the `getCreditPools` operation. */
interface GetCreditPoolsParams {
/** The ID of the billing unit. */
billingUnitId: string;
/** The date in the format of YYYY-MM. */
date?: string;
/** Filters the credit pool by type, either `PLATFORM` or `SUPPORT`. */
type?: string;
/** Return results up to this limit. Valid values are between 0 and 100. */
limit?: number;
/** The pagination offset. This represents the index of the first returned result. */
start?: string;
headers?: OutgoingHttpHeaders;
}
/*************************
* model interfaces
************************/
/** Information about a billing option. */
interface BillingOption {
/** The ID of the billing option. */
id?: string;
/** The ID of the billing unit that's associated with the billing option. */
billing_unit_id?: string;
/** The start date of billing option. */
start_date?: string;
/** The end date of billing option. */
end_date?: string;
/** The state of the billing option. The valid values include `ACTIVE, `SUSPENDED`, and `CANCELED`. */
state?: string;
/** The type of billing option. The valid values are `SUBSCRIPTION` and `OFFER`. */
type?: string;
/** The category of the billing option. The valid values are `PLATFORM`, `SERVICE`, and `SUPPORT`. */
category?: string;
/** The payment method for support. */
payment_instrument?: JsonObject;
/** The duration of the billing options in months. */
duration_in_months?: number;
/** The line item ID for support. */
line_item_id?: number;
/** The support billing system. */
billing_system?: JsonObject;
/** The renewal code for support. This code denotes whether the subscription automatically renews, is assessed
* monthly, and so on.
*/
renewal_mode_code?: string;
/** The date when the billing option was updated. */
updated_at?: string;
}
/** A search result containing zero or more billing options. */
interface BillingOptionsList {
/** A count of the billing units that were found by the query. */
rows_count?: number;
/** Bookmark URL to query for next batch of billing units. This returns `null` if no additional pages are
* required.
*/
next_url?: string;
/** A list of billing units found. */
resources?: BillingOption[];
}
/** Information about a billing unit. */
interface BillingUnit {
/** The ID of the billing unit, which is a globally unique identifier (GUID). */
id?: string;
/** The Cloud Resource Name (CRN) of the billing unit, scoped to the enterprise account ID. */
crn?: string;
/** The name of the billing unit. */
name?: string;
/** The ID of the enterprise to which the billing unit is associated. */
enterprise_id?: string;
/** The currency code for the billing unit. */
currency_code?: string;
/** The country code for the billing unit. */
country_code?: string;
/** A flag that indicates whether this billing unit is the primary billing mechanism for the enterprise. */
master?: boolean;
/** The creation date of the billing unit. */
created_at?: string;
}
/** A search result contining zero or more billing units. */
interface BillingUnitsList {
/** A count of the billing units that were found by the query. */
rows_count?: number;
/** Bookmark URL to query for next batch of billing units. This returns `null` if no additional pages are
* required.
*/
next_url?: string;
/** A list of billing units found. */
resources?: BillingUnit[];
}
/** The credit pool for a billing unit. */
interface CreditPool {
/** The type of credit, either `PLATFORM` or `SUPPORT`. */
type?: string;
/** The currency code of the associated billing unit. */
currency_code?: string;
/** The ID of the billing unit that's associated with the credit pool. This value is a globally unique
* identifier (GUID).
*/
billing_unit_id?: string;
/** A list of active subscription terms available within a credit pool. */
term_credits?: TermCredits[];
/** Overage that was generated on the credit pool. */
overage?: CreditPoolOverage;
}
/** Overage that was generated on the credit pool. */
interface CreditPoolOverage {
/** The number of credits used as overage. */
cost?: number;
/** A list of resources that generated overage. */
resources?: JsonObject[];
}
/** A search result containing zero or more credit pools. */
interface CreditPoolsList {
/** The number of credit pools that were found by the query. */
rows_count?: number;
/** A bookmark URL to the query for the next batch of billing units. Use a value of `null` if no additional
* pages are required.
*/
next_url?: string;
/** A list of credit pools found by the query. */
resources?: CreditPool[];
}
/** The subscription term that is active in the current month. */
interface TermCredits {
/** The ID of the billing option from which the subscription term is derived. */
billing_option_id?: string;
/** The category of the credit pool. The valid values are `PLATFORM`, `OFFER`, or `SERVICE` for platform credit
* and `SUPPORT` for support credit.
*/
category?: string;
/** The start date of the term in ISO format. */
start_date?: string;
/** The end date of the term in ISO format. */
end_date?: string;
/** The total credit available in this term. */
total_credits?: number;
/** The balance of available credit at the start of the current month. */
starting_balance?: number;
/** The amount of credit used during the current month. */
used_credits?: number;
/** The balance of remaining credit in the subscription term. */
current_balance?: number;
/** A list of resources that used credit during the month. */
resources?: JsonObject[];
}
/*************************
* pager classes
************************/
/**
* BillingUnitsPager can be used to simplify the use of listBillingUnits().
*/
class BillingUnitsPager {
protected _hasNext: boolean;
protected pageContext: any;
protected client: EnterpriseBillingUnitsV1;
protected params: EnterpriseBillingUnitsV1.ListBillingUnitsParams;
/**
* Construct a BillingUnitsPager object.
*
* @param {EnterpriseBillingUnitsV1} client - The service client instance used to invoke listBillingUnits()
* @param {Object} [params] - The parameters to be passed to listBillingUnits()
* @constructor
* @returns {BillingUnitsPager}
*/
constructor(client: EnterpriseBillingUnitsV1, params?: EnterpriseBillingUnitsV1.ListBillingUnitsParams);
/**
* Returns true if there are potentially more results to be retrieved by invoking getNext().
* @returns {boolean}
*/
hasNext(): boolean;
/**
* Returns the next page of results by invoking listBillingUnits().
* @returns {Promise<EnterpriseBillingUnitsV1.BillingUnit[]>}
*/
getNext(): Promise<EnterpriseBillingUnitsV1.BillingUnit[]>;
/**
* Returns all results by invoking listBillingUnits() repeatedly until all pages of results have been retrieved.
* @returns {Promise<EnterpriseBillingUnitsV1.BillingUnit[]>}
*/
getAll(): Promise<EnterpriseBillingUnitsV1.BillingUnit[]>;
}
/**
* BillingOptionsPager can be used to simplify the use of listBillingOptions().
*/
class BillingOptionsPager {
protected _hasNext: boolean;
protected pageContext: any;
protected client: EnterpriseBillingUnitsV1;
protected params: EnterpriseBillingUnitsV1.ListBillingOptionsParams;
/**
* Construct a BillingOptionsPager object.
*
* @param {EnterpriseBillingUnitsV1} client - The service client instance used to invoke listBillingOptions()
* @param {Object} params - The parameters to be passed to listBillingOptions()
* @constructor
* @returns {BillingOptionsPager}
*/
constructor(client: EnterpriseBillingUnitsV1, params: EnterpriseBillingUnitsV1.ListBillingOptionsParams);
/**
* Returns true if there are potentially more results to be retrieved by invoking getNext().
* @returns {boolean}
*/
hasNext(): boolean;
/**
* Returns the next page of results by invoking listBillingOptions().
* @returns {Promise<EnterpriseBillingUnitsV1.BillingOption[]>}
*/
getNext(): Promise<EnterpriseBillingUnitsV1.BillingOption[]>;
/**
* Returns all results by invoking listBillingOptions() repeatedly until all pages of results have been retrieved.
* @returns {Promise<EnterpriseBillingUnitsV1.BillingOption[]>}
*/
getAll(): Promise<EnterpriseBillingUnitsV1.BillingOption[]>;
}
}
export = EnterpriseBillingUnitsV1;