-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb19bbb
commit 15ddc64
Showing
9 changed files
with
339 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
configured_endpoints: 97 | ||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-77f4e8cf0fc3b3f18c894408f322af7988ae90606235fe5058442409142a33e1.yml | ||
configured_endpoints: 101 | ||
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-726c25fdf0fdd4b7c5a9c36d30e33990d2a4b63c4260be340400f8ded23b578f.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
src/resources/dimensional-price-groups/dimensional-price-groups.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | ||
|
||
import { APIResource } from '../../resource'; | ||
import { isRequestOptions } from '../../core'; | ||
import * as Core from '../../core'; | ||
import * as Shared from '../shared'; | ||
import * as ExternalDimensionalPriceGroupIDAPI from './external-dimensional-price-group-id'; | ||
import { ExternalDimensionalPriceGroupID } from './external-dimensional-price-group-id'; | ||
import { Page, type PageParams } from '../../pagination'; | ||
|
||
export class DimensionalPriceGroups extends APIResource { | ||
externalDimensionalPriceGroupId: ExternalDimensionalPriceGroupIDAPI.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 parition 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. | ||
*/ | ||
create( | ||
body: DimensionalPriceGroupCreateParams, | ||
options?: Core.RequestOptions, | ||
): Core.APIPromise<DimensionalPriceGroup> { | ||
return this._client.post('/dimensional_price_groups', { body, ...options }); | ||
} | ||
|
||
/** | ||
* Fetch dimensional price group | ||
*/ | ||
retrieve( | ||
dimensionalPriceGroupId: string, | ||
options?: Core.RequestOptions, | ||
): Core.APIPromise<DimensionalPriceGroup> { | ||
return this._client.get(`/dimensional_price_groups/${dimensionalPriceGroupId}`, options); | ||
} | ||
|
||
/** | ||
* List dimensional price groups | ||
*/ | ||
list( | ||
query?: DimensionalPriceGroupListParams, | ||
options?: Core.RequestOptions, | ||
): Core.PagePromise<DimensionalPriceGroupsPage, DimensionalPriceGroup>; | ||
list(options?: Core.RequestOptions): Core.PagePromise<DimensionalPriceGroupsPage, DimensionalPriceGroup>; | ||
list( | ||
query: DimensionalPriceGroupListParams | Core.RequestOptions = {}, | ||
options?: Core.RequestOptions, | ||
): Core.PagePromise<DimensionalPriceGroupsPage, DimensionalPriceGroup> { | ||
if (isRequestOptions(query)) { | ||
return this.list({}, query); | ||
} | ||
return this._client.getAPIList('/dimensional_price_groups', DimensionalPriceGroupsPage, { | ||
query, | ||
...options, | ||
}); | ||
} | ||
} | ||
|
||
export class DimensionalPriceGroupsPage extends Page<DimensionalPriceGroup> {} | ||
|
||
/** | ||
* 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 parition used | ||
* to derive their usage. | ||
*/ | ||
export interface DimensionalPriceGroup { | ||
id: string; | ||
|
||
/** | ||
* The billable metric associated with this dimensional price group. All prices | ||
* associated with this dimensional price group will be computed using this | ||
* billable metric. | ||
*/ | ||
billable_metric_id: string; | ||
|
||
/** | ||
* The dimensions that this dimensional price group is defined over | ||
*/ | ||
dimensions: Array<string>; | ||
|
||
/** | ||
* An alias for the dimensional price group | ||
*/ | ||
external_dimensional_price_group_id: string | null; | ||
|
||
/** | ||
* User specified key-value pairs for the resource. If not present, this defaults | ||
* to an empty dictionary. Individual keys can be removed by setting the value to | ||
* `null`, and the entire metadata mapping can be cleared by setting `metadata` to | ||
* `null`. | ||
*/ | ||
metadata: Record<string, string>; | ||
|
||
/** | ||
* The name of the dimensional price group | ||
*/ | ||
name: string; | ||
} | ||
|
||
export interface DimensionalPriceGroups { | ||
data: Array<DimensionalPriceGroup>; | ||
|
||
pagination_metadata: Shared.PaginationMetadata; | ||
} | ||
|
||
export interface DimensionalPriceGroupCreateParams { | ||
billable_metric_id: string; | ||
|
||
/** | ||
* The set of keys (in order) used to disambiguate prices in the group. | ||
*/ | ||
dimensions: Array<string>; | ||
|
||
name: string; | ||
|
||
external_dimensional_price_group_id?: string | null; | ||
|
||
/** | ||
* User-specified key/value pairs for the resource. Individual keys can be removed | ||
* by setting the value to `null`, and the entire metadata mapping can be cleared | ||
* by setting `metadata` to `null`. | ||
*/ | ||
metadata?: Record<string, string | null> | null; | ||
} | ||
|
||
export interface DimensionalPriceGroupListParams extends PageParams {} | ||
|
||
DimensionalPriceGroups.DimensionalPriceGroupsPage = DimensionalPriceGroupsPage; | ||
DimensionalPriceGroups.ExternalDimensionalPriceGroupID = ExternalDimensionalPriceGroupID; | ||
|
||
export declare namespace DimensionalPriceGroups { | ||
export { | ||
type DimensionalPriceGroup as DimensionalPriceGroup, | ||
type DimensionalPriceGroups as DimensionalPriceGroups, | ||
DimensionalPriceGroupsPage as DimensionalPriceGroupsPage, | ||
type DimensionalPriceGroupCreateParams as DimensionalPriceGroupCreateParams, | ||
type DimensionalPriceGroupListParams as DimensionalPriceGroupListParams, | ||
}; | ||
|
||
export { ExternalDimensionalPriceGroupID as ExternalDimensionalPriceGroupID }; | ||
} |
20 changes: 20 additions & 0 deletions
20
src/resources/dimensional-price-groups/external-dimensional-price-group-id.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | ||
|
||
import { APIResource } from '../../resource'; | ||
import * as Core from '../../core'; | ||
import * as DimensionalPriceGroupsAPI from './dimensional-price-groups'; | ||
|
||
export class ExternalDimensionalPriceGroupID extends APIResource { | ||
/** | ||
* Fetch dimensional price group by external ID | ||
*/ | ||
retrieve( | ||
externalDimensionalPriceGroupId: string, | ||
options?: Core.RequestOptions, | ||
): Core.APIPromise<DimensionalPriceGroupsAPI.DimensionalPriceGroup> { | ||
return this._client.get( | ||
`/dimensional_price_groups/external_dimensional_price_group_id/${externalDimensionalPriceGroupId}`, | ||
options, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | ||
|
||
export { | ||
DimensionalPriceGroupsPage, | ||
type DimensionalPriceGroups, | ||
type DimensionalPriceGroup, | ||
type DimensionalPriceGroupCreateParams, | ||
type DimensionalPriceGroupListParams, | ||
} from './dimensional-price-groups'; | ||
export { ExternalDimensionalPriceGroupID } from './external-dimensional-price-group-id'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
tests/api-resources/dimensional-price-groups/dimensional-price-groups.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | ||
|
||
import Orb from 'orb-billing'; | ||
import { Response } from 'node-fetch'; | ||
|
||
const client = new Orb({ | ||
apiKey: 'My API Key', | ||
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', | ||
}); | ||
|
||
describe('resource dimensionalPriceGroups', () => { | ||
test('create: only required params', async () => { | ||
const responsePromise = client.dimensionalPriceGroups.create({ | ||
billable_metric_id: 'billable_metric_id', | ||
dimensions: ['region', 'instance_type'], | ||
name: 'name', | ||
}); | ||
const rawResponse = await responsePromise.asResponse(); | ||
expect(rawResponse).toBeInstanceOf(Response); | ||
const response = await responsePromise; | ||
expect(response).not.toBeInstanceOf(Response); | ||
const dataAndResponse = await responsePromise.withResponse(); | ||
expect(dataAndResponse.data).toBe(response); | ||
expect(dataAndResponse.response).toBe(rawResponse); | ||
}); | ||
|
||
test('create: required and optional params', async () => { | ||
const response = await client.dimensionalPriceGroups.create({ | ||
billable_metric_id: 'billable_metric_id', | ||
dimensions: ['region', 'instance_type'], | ||
name: 'name', | ||
external_dimensional_price_group_id: 'external_dimensional_price_group_id', | ||
metadata: { foo: 'string' }, | ||
}); | ||
}); | ||
|
||
test('retrieve', async () => { | ||
const responsePromise = client.dimensionalPriceGroups.retrieve('dimensional_price_group_id'); | ||
const rawResponse = await responsePromise.asResponse(); | ||
expect(rawResponse).toBeInstanceOf(Response); | ||
const response = await responsePromise; | ||
expect(response).not.toBeInstanceOf(Response); | ||
const dataAndResponse = await responsePromise.withResponse(); | ||
expect(dataAndResponse.data).toBe(response); | ||
expect(dataAndResponse.response).toBe(rawResponse); | ||
}); | ||
|
||
test('retrieve: request options instead of params are passed correctly', async () => { | ||
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error | ||
await expect( | ||
client.dimensionalPriceGroups.retrieve('dimensional_price_group_id', { | ||
path: '/_stainless_unknown_path', | ||
}), | ||
).rejects.toThrow(Orb.NotFoundError); | ||
}); | ||
|
||
test('list', async () => { | ||
const responsePromise = client.dimensionalPriceGroups.list(); | ||
const rawResponse = await responsePromise.asResponse(); | ||
expect(rawResponse).toBeInstanceOf(Response); | ||
const response = await responsePromise; | ||
expect(response).not.toBeInstanceOf(Response); | ||
const dataAndResponse = await responsePromise.withResponse(); | ||
expect(dataAndResponse.data).toBe(response); | ||
expect(dataAndResponse.response).toBe(rawResponse); | ||
}); | ||
|
||
test('list: request options instead of params are passed correctly', async () => { | ||
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error | ||
await expect(client.dimensionalPriceGroups.list({ path: '/_stainless_unknown_path' })).rejects.toThrow( | ||
Orb.NotFoundError, | ||
); | ||
}); | ||
|
||
test('list: request options and params are passed correctly', async () => { | ||
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error | ||
await expect( | ||
client.dimensionalPriceGroups.list( | ||
{ cursor: 'cursor', limit: 1 }, | ||
{ path: '/_stainless_unknown_path' }, | ||
), | ||
).rejects.toThrow(Orb.NotFoundError); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
tests/api-resources/dimensional-price-groups/external-dimensional-price-group-id.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. | ||
|
||
import Orb from 'orb-billing'; | ||
import { Response } from 'node-fetch'; | ||
|
||
const client = new Orb({ | ||
apiKey: 'My API Key', | ||
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', | ||
}); | ||
|
||
describe('resource externalDimensionalPriceGroupId', () => { | ||
test('retrieve', async () => { | ||
const responsePromise = client.dimensionalPriceGroups.externalDimensionalPriceGroupId.retrieve( | ||
'external_dimensional_price_group_id', | ||
); | ||
const rawResponse = await responsePromise.asResponse(); | ||
expect(rawResponse).toBeInstanceOf(Response); | ||
const response = await responsePromise; | ||
expect(response).not.toBeInstanceOf(Response); | ||
const dataAndResponse = await responsePromise.withResponse(); | ||
expect(dataAndResponse.data).toBe(response); | ||
expect(dataAndResponse.response).toBe(rawResponse); | ||
}); | ||
|
||
test('retrieve: request options instead of params are passed correctly', async () => { | ||
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error | ||
await expect( | ||
client.dimensionalPriceGroups.externalDimensionalPriceGroupId.retrieve( | ||
'external_dimensional_price_group_id', | ||
{ path: '/_stainless_unknown_path' }, | ||
), | ||
).rejects.toThrow(Orb.NotFoundError); | ||
}); | ||
}); |