|
| 1 | +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +import { APIResource } from '../../resource'; |
| 4 | +import { isRequestOptions } from '../../core'; |
| 5 | +import * as Core from '../../core'; |
| 6 | +import * as Shared from '../shared'; |
| 7 | +import * as ExternalDimensionalPriceGroupIDAPI from './external-dimensional-price-group-id'; |
| 8 | +import { ExternalDimensionalPriceGroupID } from './external-dimensional-price-group-id'; |
| 9 | +import { Page, type PageParams } from '../../pagination'; |
| 10 | + |
| 11 | +export class DimensionalPriceGroups extends APIResource { |
| 12 | + externalDimensionalPriceGroupId: ExternalDimensionalPriceGroupIDAPI.ExternalDimensionalPriceGroupID = |
| 13 | + new ExternalDimensionalPriceGroupIDAPI.ExternalDimensionalPriceGroupID(this._client); |
| 14 | + |
| 15 | + /** |
| 16 | + * A dimensional price group is used to partition the result of a billable metric |
| 17 | + * by a set of dimensions. Prices in a price group must specify the parition used |
| 18 | + * to derive their usage. |
| 19 | + * |
| 20 | + * For example, suppose we have a billable metric that measures the number of |
| 21 | + * widgets used and we want to charge differently depending on the color of the |
| 22 | + * widget. We can create a price group with a dimension "color" and two prices: one |
| 23 | + * that charges $10 per red widget and one that charges $20 per blue widget. |
| 24 | + */ |
| 25 | + create( |
| 26 | + body: DimensionalPriceGroupCreateParams, |
| 27 | + options?: Core.RequestOptions, |
| 28 | + ): Core.APIPromise<DimensionalPriceGroup> { |
| 29 | + return this._client.post('/dimensional_price_groups', { body, ...options }); |
| 30 | + } |
| 31 | + |
| 32 | + /** |
| 33 | + * Fetch dimensional price group |
| 34 | + */ |
| 35 | + retrieve( |
| 36 | + dimensionalPriceGroupId: string, |
| 37 | + options?: Core.RequestOptions, |
| 38 | + ): Core.APIPromise<DimensionalPriceGroup> { |
| 39 | + return this._client.get(`/dimensional_price_groups/${dimensionalPriceGroupId}`, options); |
| 40 | + } |
| 41 | + |
| 42 | + /** |
| 43 | + * List dimensional price groups |
| 44 | + */ |
| 45 | + list( |
| 46 | + query?: DimensionalPriceGroupListParams, |
| 47 | + options?: Core.RequestOptions, |
| 48 | + ): Core.PagePromise<DimensionalPriceGroupsPage, DimensionalPriceGroup>; |
| 49 | + list(options?: Core.RequestOptions): Core.PagePromise<DimensionalPriceGroupsPage, DimensionalPriceGroup>; |
| 50 | + list( |
| 51 | + query: DimensionalPriceGroupListParams | Core.RequestOptions = {}, |
| 52 | + options?: Core.RequestOptions, |
| 53 | + ): Core.PagePromise<DimensionalPriceGroupsPage, DimensionalPriceGroup> { |
| 54 | + if (isRequestOptions(query)) { |
| 55 | + return this.list({}, query); |
| 56 | + } |
| 57 | + return this._client.getAPIList('/dimensional_price_groups', DimensionalPriceGroupsPage, { |
| 58 | + query, |
| 59 | + ...options, |
| 60 | + }); |
| 61 | + } |
| 62 | +} |
| 63 | + |
| 64 | +export class DimensionalPriceGroupsPage extends Page<DimensionalPriceGroup> {} |
| 65 | + |
| 66 | +/** |
| 67 | + * A dimensional price group is used to partition the result of a billable metric |
| 68 | + * by a set of dimensions. Prices in a price group must specify the parition used |
| 69 | + * to derive their usage. |
| 70 | + */ |
| 71 | +export interface DimensionalPriceGroup { |
| 72 | + id: string; |
| 73 | + |
| 74 | + /** |
| 75 | + * The billable metric associated with this dimensional price group. All prices |
| 76 | + * associated with this dimensional price group will be computed using this |
| 77 | + * billable metric. |
| 78 | + */ |
| 79 | + billable_metric_id: string; |
| 80 | + |
| 81 | + /** |
| 82 | + * The dimensions that this dimensional price group is defined over |
| 83 | + */ |
| 84 | + dimensions: Array<string>; |
| 85 | + |
| 86 | + /** |
| 87 | + * An alias for the dimensional price group |
| 88 | + */ |
| 89 | + external_dimensional_price_group_id: string | null; |
| 90 | + |
| 91 | + /** |
| 92 | + * User specified key-value pairs for the resource. If not present, this defaults |
| 93 | + * to an empty dictionary. Individual keys can be removed by setting the value to |
| 94 | + * `null`, and the entire metadata mapping can be cleared by setting `metadata` to |
| 95 | + * `null`. |
| 96 | + */ |
| 97 | + metadata: Record<string, string>; |
| 98 | + |
| 99 | + /** |
| 100 | + * The name of the dimensional price group |
| 101 | + */ |
| 102 | + name: string; |
| 103 | +} |
| 104 | + |
| 105 | +export interface DimensionalPriceGroups { |
| 106 | + data: Array<DimensionalPriceGroup>; |
| 107 | + |
| 108 | + pagination_metadata: Shared.PaginationMetadata; |
| 109 | +} |
| 110 | + |
| 111 | +export interface DimensionalPriceGroupCreateParams { |
| 112 | + billable_metric_id: string; |
| 113 | + |
| 114 | + /** |
| 115 | + * The set of keys (in order) used to disambiguate prices in the group. |
| 116 | + */ |
| 117 | + dimensions: Array<string>; |
| 118 | + |
| 119 | + name: string; |
| 120 | + |
| 121 | + external_dimensional_price_group_id?: string | null; |
| 122 | + |
| 123 | + /** |
| 124 | + * User-specified key/value pairs for the resource. Individual keys can be removed |
| 125 | + * by setting the value to `null`, and the entire metadata mapping can be cleared |
| 126 | + * by setting `metadata` to `null`. |
| 127 | + */ |
| 128 | + metadata?: Record<string, string | null> | null; |
| 129 | +} |
| 130 | + |
| 131 | +export interface DimensionalPriceGroupListParams extends PageParams {} |
| 132 | + |
| 133 | +DimensionalPriceGroups.DimensionalPriceGroupsPage = DimensionalPriceGroupsPage; |
| 134 | +DimensionalPriceGroups.ExternalDimensionalPriceGroupID = ExternalDimensionalPriceGroupID; |
| 135 | + |
| 136 | +export declare namespace DimensionalPriceGroups { |
| 137 | + export { |
| 138 | + type DimensionalPriceGroup as DimensionalPriceGroup, |
| 139 | + type DimensionalPriceGroups as DimensionalPriceGroups, |
| 140 | + DimensionalPriceGroupsPage as DimensionalPriceGroupsPage, |
| 141 | + type DimensionalPriceGroupCreateParams as DimensionalPriceGroupCreateParams, |
| 142 | + type DimensionalPriceGroupListParams as DimensionalPriceGroupListParams, |
| 143 | + }; |
| 144 | + |
| 145 | + export { ExternalDimensionalPriceGroupID as ExternalDimensionalPriceGroupID }; |
| 146 | +} |
0 commit comments