cloudflare
Version:
The official TypeScript library for the Cloudflare API
112 lines • 5.03 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../core/resource.mjs";
import { path } from "../../internal/utils/path.mjs";
export var BaseUsage = /* @__PURE__ */ (() => {
class BaseUsage extends APIResource {
/**
* Returns cost and usage data for a single Cloudflare account, aligned with the
* [FinOps FOCUS v1.3](https://focus.finops.org/focus-specification/v1-3/) Cost and
* Usage dataset specification.
*
* Each record represents one billable metric for one account on one day. This
* includes all metered usage, including usage that falls within free-tier
* allowances and may result in zero cost.
*
* **Note:** Cost and pricing fields are not yet populated and will be absent from
* responses until billing integration is complete.
*
* When `from` and `to` are omitted, defaults to the start of the current month
* through today. The maximum date range is 31 days.
*
* @deprecated Use `get_account_usage_v2` instead.
*/
get(params, options) {
const { account_id, ...query } = params;
return this._client.get(path `/accounts/${account_id}/billable/usage`, { query, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Returns high-level usage information for the account, including coverage, and
* subscription metadata.
*
* @example
* ```ts
* const response =
* await client.billing.usage.getAccountUsageInfoV1({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
getAccountUsageInfoV1(params, options) {
const { account_id } = params;
return this._client.get(path `/accounts/${account_id}/billable-usage/info`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Returns billable usage data for the account. When no query parameters are
* provided, returns usage for the current billing period.
*
* @example
* ```ts
* const response =
* await client.billing.usage.getAccountUsageV1({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
getAccountUsageV1(params, options) {
const { account_id, ...query } = params;
return this._client.get(path `/accounts/${account_id}/billable-usage`, { query, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Returns cost and usage data for a single Cloudflare account, aligned with the
* [FinOps FOCUS v1.3](https://focus.finops.org/focus-specification/v1-3/) Cost and
* Usage dataset specification.
*
* Each record represents one billable metric for one account on one day. This
* includes all metered usage, including usage that falls within free-tier
* allowances and may result in zero cost.
*
* **Note:** Cost and pricing fields are not yet populated and will be absent from
* responses until billing integration is complete.
*
* When `from` and `to` are omitted, defaults to the start of the current month
* through today. The maximum date range is 31 days.
*
* @example
* ```ts
* const response =
* await client.billing.usage.getAccountUsageV2({
* account_id: '023e105f4ecef8ad9ca31a8372d0c353',
* });
* ```
*/
getAccountUsageV2(params, options) {
const { account_id, ...query } = params;
return this._client.get(path `/accounts/${account_id}/billable/usage`, { query, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Returns billable usage data for the account. When no query parameters are
* provided, returns usage for the current billing period.
*
* @deprecated Use `get_account_usage_v1` instead.
*/
paygo(params, options) {
const { account_id, ...query } = params;
return this._client.get(path `/accounts/${account_id}/billable-usage`, { query, ...options })._thenUnwrap((obj) => obj.result);
}
/**
* Returns high-level usage information for the account, including coverage, and
* subscription metadata.
*
* @deprecated Use `get_account_usage_info_v1` instead.
*/
paygoInfo(params, options) {
const { account_id } = params;
return this._client.get(path `/accounts/${account_id}/billable-usage/info`, options)._thenUnwrap((obj) => obj.result);
}
}
BaseUsage._key = Object.freeze(['billing', 'usage']);
return BaseUsage;
})();
export class Usage extends BaseUsage {
}
//# sourceMappingURL=usage.mjs.map