Skip to content

Commit 35ab9da

Browse files
feat(api): api update (#432)
1 parent cb19bbb commit 35ab9da

File tree

9 files changed

+339
-2
lines changed

9 files changed

+339
-2
lines changed

.stats.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 97
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-77f4e8cf0fc3b3f18c894408f322af7988ae90606235fe5058442409142a33e1.yml
1+
configured_endpoints: 101
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-726c25fdf0fdd4b7c5a9c36d30e33990d2a4b63c4260be340400f8ded23b578f.yml

api.md

+19
Original file line numberDiff line numberDiff line change
@@ -334,3 +334,22 @@ Methods:
334334
- <code title="post /alerts/subscription_id/{subscription_id}">client.alerts.<a href="./src/resources/alerts.ts">createForSubscription</a>(subscriptionId, { ...params }) -> Alert</code>
335335
- <code title="post /alerts/{alert_configuration_id}/disable">client.alerts.<a href="./src/resources/alerts.ts">disable</a>(alertConfigurationId, { ...params }) -> Alert</code>
336336
- <code title="post /alerts/{alert_configuration_id}/enable">client.alerts.<a href="./src/resources/alerts.ts">enable</a>(alertConfigurationId, { ...params }) -> Alert</code>
337+
338+
# DimensionalPriceGroups
339+
340+
Types:
341+
342+
- <code><a href="./src/resources/dimensional-price-groups/dimensional-price-groups.ts">DimensionalPriceGroup</a></code>
343+
- <code><a href="./src/resources/dimensional-price-groups/dimensional-price-groups.ts">DimensionalPriceGroups</a></code>
344+
345+
Methods:
346+
347+
- <code title="post /dimensional_price_groups">client.dimensionalPriceGroups.<a href="./src/resources/dimensional-price-groups/dimensional-price-groups.ts">create</a>({ ...params }) -> DimensionalPriceGroup</code>
348+
- <code title="get /dimensional_price_groups/{dimensional_price_group_id}">client.dimensionalPriceGroups.<a href="./src/resources/dimensional-price-groups/dimensional-price-groups.ts">retrieve</a>(dimensionalPriceGroupId) -> DimensionalPriceGroup</code>
349+
- <code title="get /dimensional_price_groups">client.dimensionalPriceGroups.<a href="./src/resources/dimensional-price-groups/dimensional-price-groups.ts">list</a>({ ...params }) -> DimensionalPriceGroupsPage</code>
350+
351+
## ExternalDimensionalPriceGroupID
352+
353+
Methods:
354+
355+
- <code title="get /dimensional_price_groups/external_dimensional_price_group_id/{external_dimensional_price_group_id}">client.dimensionalPriceGroups.externalDimensionalPriceGroupId.<a href="./src/resources/dimensional-price-groups/external-dimensional-price-group-id.ts">retrieve</a>(externalDimensionalPriceGroupId) -> DimensionalPriceGroup</code>

src/index.ts

+17
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ import {
109109
Customers,
110110
CustomersPage,
111111
} from './resources/customers/customers';
112+
import {
113+
DimensionalPriceGroup,
114+
DimensionalPriceGroupCreateParams,
115+
DimensionalPriceGroupListParams,
116+
DimensionalPriceGroups,
117+
DimensionalPriceGroupsPage,
118+
} from './resources/dimensional-price-groups/dimensional-price-groups';
112119
import {
113120
EventDeprecateResponse,
114121
EventIngestParams,
@@ -277,6 +284,7 @@ export class Orb extends Core.APIClient {
277284
subscriptions: API.Subscriptions = new API.Subscriptions(this);
278285
webhooks: API.Webhooks = new API.Webhooks(this);
279286
alerts: API.Alerts = new API.Alerts(this);
287+
dimensionalPriceGroups: API.DimensionalPriceGroups = new API.DimensionalPriceGroups(this);
280288

281289
protected override defaultQuery(): Core.DefaultQuery | undefined {
282290
return this._options.defaultQuery;
@@ -353,6 +361,7 @@ Orb.SubscriptionsPage = SubscriptionsPage;
353361
Orb.SubscriptionFetchScheduleResponsesPage = SubscriptionFetchScheduleResponsesPage;
354362
Orb.Alerts = Alerts;
355363
Orb.AlertsPage = AlertsPage;
364+
Orb.DimensionalPriceGroupsPage = DimensionalPriceGroupsPage;
356365
export declare namespace Orb {
357366
export type RequestOptions = Core.RequestOptions;
358367

@@ -502,6 +511,14 @@ export declare namespace Orb {
502511
type AlertEnableParams as AlertEnableParams,
503512
};
504513

514+
export {
515+
type DimensionalPriceGroups as DimensionalPriceGroups,
516+
type DimensionalPriceGroup as DimensionalPriceGroup,
517+
DimensionalPriceGroupsPage as DimensionalPriceGroupsPage,
518+
type DimensionalPriceGroupCreateParams as DimensionalPriceGroupCreateParams,
519+
type DimensionalPriceGroupListParams as DimensionalPriceGroupListParams,
520+
};
521+
505522
export type AmountDiscount = API.AmountDiscount;
506523
export type BillingCycleRelativeDate = API.BillingCycleRelativeDate;
507524
export type Discount = API.Discount;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import { APIResource } from '../../resource';
4+
import * as Core from '../../core';
5+
import * as DimensionalPriceGroupsAPI from './dimensional-price-groups';
6+
7+
export class ExternalDimensionalPriceGroupID extends APIResource {
8+
/**
9+
* Fetch dimensional price group by external ID
10+
*/
11+
retrieve(
12+
externalDimensionalPriceGroupId: string,
13+
options?: Core.RequestOptions,
14+
): Core.APIPromise<DimensionalPriceGroupsAPI.DimensionalPriceGroup> {
15+
return this._client.get(
16+
`/dimensional_price_groups/external_dimensional_price_group_id/${externalDimensionalPriceGroupId}`,
17+
options,
18+
);
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
export {
4+
DimensionalPriceGroupsPage,
5+
type DimensionalPriceGroups,
6+
type DimensionalPriceGroup,
7+
type DimensionalPriceGroupCreateParams,
8+
type DimensionalPriceGroupListParams,
9+
} from './dimensional-price-groups';
10+
export { ExternalDimensionalPriceGroupID } from './external-dimensional-price-group-id';

src/resources/index.ts

+7
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ export {
4444
type CustomerListParams,
4545
type CustomerUpdateByExternalIDParams,
4646
} from './customers/customers';
47+
export {
48+
DimensionalPriceGroupsPage,
49+
type DimensionalPriceGroups,
50+
type DimensionalPriceGroup,
51+
type DimensionalPriceGroupCreateParams,
52+
type DimensionalPriceGroupListParams,
53+
} from './dimensional-price-groups/dimensional-price-groups';
4754
export {
4855
Events,
4956
type EventUpdateResponse,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import Orb from 'orb-billing';
4+
import { Response } from 'node-fetch';
5+
6+
const client = new Orb({
7+
apiKey: 'My API Key',
8+
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
9+
});
10+
11+
describe('resource dimensionalPriceGroups', () => {
12+
test('create: only required params', async () => {
13+
const responsePromise = client.dimensionalPriceGroups.create({
14+
billable_metric_id: 'billable_metric_id',
15+
dimensions: ['region', 'instance_type'],
16+
name: 'name',
17+
});
18+
const rawResponse = await responsePromise.asResponse();
19+
expect(rawResponse).toBeInstanceOf(Response);
20+
const response = await responsePromise;
21+
expect(response).not.toBeInstanceOf(Response);
22+
const dataAndResponse = await responsePromise.withResponse();
23+
expect(dataAndResponse.data).toBe(response);
24+
expect(dataAndResponse.response).toBe(rawResponse);
25+
});
26+
27+
test('create: required and optional params', async () => {
28+
const response = await client.dimensionalPriceGroups.create({
29+
billable_metric_id: 'billable_metric_id',
30+
dimensions: ['region', 'instance_type'],
31+
name: 'name',
32+
external_dimensional_price_group_id: 'external_dimensional_price_group_id',
33+
metadata: { foo: 'string' },
34+
});
35+
});
36+
37+
test('retrieve', async () => {
38+
const responsePromise = client.dimensionalPriceGroups.retrieve('dimensional_price_group_id');
39+
const rawResponse = await responsePromise.asResponse();
40+
expect(rawResponse).toBeInstanceOf(Response);
41+
const response = await responsePromise;
42+
expect(response).not.toBeInstanceOf(Response);
43+
const dataAndResponse = await responsePromise.withResponse();
44+
expect(dataAndResponse.data).toBe(response);
45+
expect(dataAndResponse.response).toBe(rawResponse);
46+
});
47+
48+
test('retrieve: request options instead of params are passed correctly', async () => {
49+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
50+
await expect(
51+
client.dimensionalPriceGroups.retrieve('dimensional_price_group_id', {
52+
path: '/_stainless_unknown_path',
53+
}),
54+
).rejects.toThrow(Orb.NotFoundError);
55+
});
56+
57+
test('list', async () => {
58+
const responsePromise = client.dimensionalPriceGroups.list();
59+
const rawResponse = await responsePromise.asResponse();
60+
expect(rawResponse).toBeInstanceOf(Response);
61+
const response = await responsePromise;
62+
expect(response).not.toBeInstanceOf(Response);
63+
const dataAndResponse = await responsePromise.withResponse();
64+
expect(dataAndResponse.data).toBe(response);
65+
expect(dataAndResponse.response).toBe(rawResponse);
66+
});
67+
68+
test('list: request options instead of params are passed correctly', async () => {
69+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
70+
await expect(client.dimensionalPriceGroups.list({ path: '/_stainless_unknown_path' })).rejects.toThrow(
71+
Orb.NotFoundError,
72+
);
73+
});
74+
75+
test('list: request options and params are passed correctly', async () => {
76+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
77+
await expect(
78+
client.dimensionalPriceGroups.list(
79+
{ cursor: 'cursor', limit: 1 },
80+
{ path: '/_stainless_unknown_path' },
81+
),
82+
).rejects.toThrow(Orb.NotFoundError);
83+
});
84+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import Orb from 'orb-billing';
4+
import { Response } from 'node-fetch';
5+
6+
const client = new Orb({
7+
apiKey: 'My API Key',
8+
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
9+
});
10+
11+
describe('resource externalDimensionalPriceGroupId', () => {
12+
test('retrieve', async () => {
13+
const responsePromise = client.dimensionalPriceGroups.externalDimensionalPriceGroupId.retrieve(
14+
'external_dimensional_price_group_id',
15+
);
16+
const rawResponse = await responsePromise.asResponse();
17+
expect(rawResponse).toBeInstanceOf(Response);
18+
const response = await responsePromise;
19+
expect(response).not.toBeInstanceOf(Response);
20+
const dataAndResponse = await responsePromise.withResponse();
21+
expect(dataAndResponse.data).toBe(response);
22+
expect(dataAndResponse.response).toBe(rawResponse);
23+
});
24+
25+
test('retrieve: request options instead of params are passed correctly', async () => {
26+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
27+
await expect(
28+
client.dimensionalPriceGroups.externalDimensionalPriceGroupId.retrieve(
29+
'external_dimensional_price_group_id',
30+
{ path: '/_stainless_unknown_path' },
31+
),
32+
).rejects.toThrow(Orb.NotFoundError);
33+
});
34+
});

0 commit comments

Comments
 (0)