UNPKG

orb-billing

Version:

The official TypeScript library for the Orb API

84 lines 3.23 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import * as ExternalDimensionalPriceGroupIDAPI from "./external-dimensional-price-group-id.mjs"; import { ExternalDimensionalPriceGroupID, } from "./external-dimensional-price-group-id.mjs"; import { Page } from "../../core/pagination.mjs"; import { path } from "../../internal/utils/path.mjs"; export class DimensionalPriceGroups extends APIResource { constructor() { super(...arguments); this.externalDimensionalPriceGroupID = new ExternalDimensionalPriceGroupIDAPI.ExternalDimensionalPriceGroupID(this._client); } /** * A dimensional price group is used to partition the result of a billable metric * by a set of dimensions. Prices in a price group must specify the partition used * to derive their usage. * * For example, suppose we have a billable metric that measures the number of * widgets used and we want to charge differently depending on the color of the * widget. We can create a price group with a dimension "color" and two prices: one * that charges \$10 per red widget and one that charges \$20 per blue widget. * * @example * ```ts * const dimensionalPriceGroup = * await client.dimensionalPriceGroups.create({ * billable_metric_id: 'billable_metric_id', * dimensions: ['region', 'instance_type'], * name: 'name', * }); * ``` */ create(body, options) { return this._client.post('/dimensional_price_groups', { body, ...options }); } /** * Fetch dimensional price group * * @example * ```ts * const dimensionalPriceGroup = * await client.dimensionalPriceGroups.retrieve( * 'dimensional_price_group_id', * ); * ``` */ retrieve(dimensionalPriceGroupID, options) { return this._client.get(path `/dimensional_price_groups/${dimensionalPriceGroupID}`, options); } /** * This endpoint can be used to update the `external_dimensional_price_group_id` * and `metadata` of an existing dimensional price group. Other fields on a * dimensional price group are currently immutable. * * @example * ```ts * const dimensionalPriceGroup = * await client.dimensionalPriceGroups.update( * 'dimensional_price_group_id', * ); * ``` */ update(dimensionalPriceGroupID, body, options) { return this._client.put(path `/dimensional_price_groups/${dimensionalPriceGroupID}`, { body, ...options }); } /** * List dimensional price groups * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const dimensionalPriceGroup of client.dimensionalPriceGroups.list()) { * // ... * } * ``` */ list(query = {}, options) { return this._client.getAPIList('/dimensional_price_groups', (Page), { query, ...options, }); } } DimensionalPriceGroups.ExternalDimensionalPriceGroupID = ExternalDimensionalPriceGroupID; //# sourceMappingURL=dimensional-price-groups.mjs.map