@openmeter/client 1.0.0-beta-72c0e4789aae → 1.0.0-beta-e609679efd27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +125 -149
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/lib/version.d.ts +1 -1
- package/dist/lib/version.js +1 -1
- package/dist/sdk/apps.d.ts +52 -2
- package/dist/sdk/apps.js +63 -1
- package/dist/sdk/charges.d.ts +32 -0
- package/dist/sdk/charges.js +38 -0
- package/dist/sdk/currencies.d.ts +71 -0
- package/dist/sdk/currencies.js +87 -0
- package/dist/sdk/customers.d.ts +205 -2
- package/dist/sdk/customers.js +246 -1
- package/dist/sdk/entitlementAccess.d.ts +22 -0
- package/dist/sdk/entitlementAccess.js +26 -0
- package/dist/sdk/entitlements.d.ts +59 -1
- package/dist/sdk/entitlements.js +71 -1
- package/dist/sdk/grants.d.ts +43 -0
- package/dist/sdk/grants.js +51 -0
- package/dist/sdk/internal.d.ts +1 -756
- package/dist/sdk/internal.js +1 -936
- package/dist/sdk/planAddons.d.ts +20 -1
- package/dist/sdk/planAddons.js +24 -1
- package/dist/sdk/sdk.d.ts +18 -0
- package/dist/sdk/sdk.js +30 -0
- package/dist/sdk/subscriptions.d.ts +39 -1
- package/dist/sdk/subscriptions.js +45 -1
- package/package.json +1 -1
package/dist/sdk/customers.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
|
|
2
2
|
import { unwrap } from '../lib/types.js';
|
|
3
3
|
import { paginateCursor, paginatePages } from '../lib/paginate.js';
|
|
4
|
-
import { createCustomer, getCustomer, listCustomers, upsertCustomer, deleteCustomer, getCustomerBilling, updateCustomerBilling, updateCustomerBillingAppData, createCustomerStripeCheckoutSession, createCustomerStripePortalSession, createCreditGrant, getCreditGrant, listCreditGrants, getCustomerCreditBalance, createCreditAdjustment, updateCreditGrantExternalSettlement, listCreditTransactions, } from '../funcs/customers.js';
|
|
4
|
+
import { createCustomer, getCustomer, listCustomers, upsertCustomer, deleteCustomer, getCustomerBilling, updateCustomerBilling, updateCustomerBillingAppData, createCustomerStripeCheckoutSession, createCustomerStripePortalSession, createCustomerEntitlement, overrideCustomerEntitlement, getCustomerEntitlementHistory, getCustomerEntitlement, listCustomerEntitlements, resetCustomerEntitlementUsage, deleteCustomerEntitlement, createCustomerEntitlementGrant, listCustomerEntitlementGrants, createCreditGrant, getCreditGrant, listCreditGrants, getCustomerCreditBalance, createCreditAdjustment, voidCreditGrant, updateCreditGrantExternalSettlement, listCreditTransactions, listCustomerCharges, createCustomerCharges, } from '../funcs/customers.js';
|
|
5
5
|
export class Customers {
|
|
6
6
|
_client;
|
|
7
7
|
constructor(_client) {
|
|
@@ -61,10 +61,18 @@ export class Customers {
|
|
|
61
61
|
get billing() {
|
|
62
62
|
return (this._billing ??= new CustomersBilling(this._client));
|
|
63
63
|
}
|
|
64
|
+
_entitlements;
|
|
65
|
+
get entitlements() {
|
|
66
|
+
return (this._entitlements ??= new CustomersEntitlements(this._client));
|
|
67
|
+
}
|
|
64
68
|
_credits;
|
|
65
69
|
get credits() {
|
|
66
70
|
return (this._credits ??= new CustomersCredits(this._client));
|
|
67
71
|
}
|
|
72
|
+
_charges;
|
|
73
|
+
get charges() {
|
|
74
|
+
return (this._charges ??= new CustomersCharges(this._client));
|
|
75
|
+
}
|
|
68
76
|
}
|
|
69
77
|
export class CustomersBilling {
|
|
70
78
|
_client;
|
|
@@ -131,6 +139,181 @@ export class CustomersBilling {
|
|
|
131
139
|
return unwrap(await createCustomerStripePortalSession(this._client, request, options));
|
|
132
140
|
}
|
|
133
141
|
}
|
|
142
|
+
export class CustomersEntitlements {
|
|
143
|
+
_client;
|
|
144
|
+
constructor(_client) {
|
|
145
|
+
this._client = _client;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Create customer entitlement
|
|
149
|
+
*
|
|
150
|
+
* Create an entitlement for the customer.
|
|
151
|
+
*
|
|
152
|
+
* A customer can have only one active entitlement per feature. The feature must be
|
|
153
|
+
* compatible with the entitlement type. Entitlements cannot be modified after
|
|
154
|
+
* creation, only deleted.
|
|
155
|
+
*
|
|
156
|
+
* POST /openmeter/customers/{customerId}/entitlements
|
|
157
|
+
*/
|
|
158
|
+
async create(request, options) {
|
|
159
|
+
return unwrap(await createCustomerEntitlement(this._client, request, options));
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Override customer entitlement
|
|
163
|
+
*
|
|
164
|
+
* Override an entitlement of the customer with a new one.
|
|
165
|
+
*
|
|
166
|
+
* The referenced entitlement ends and the new one starts at the same instant, so
|
|
167
|
+
* access continues without a gap. Both must belong to the same feature. Use this
|
|
168
|
+
* for upgrades and downgrades.
|
|
169
|
+
*
|
|
170
|
+
* Fails if the referenced entitlement does not exist, is deleted, or is no longer
|
|
171
|
+
* active.
|
|
172
|
+
*
|
|
173
|
+
* PUT /openmeter/customers/{customerId}/entitlements/{entitlementId}/override
|
|
174
|
+
*/
|
|
175
|
+
async override(request, options) {
|
|
176
|
+
return unwrap(await overrideCustomerEntitlement(this._client, request, options));
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Get customer entitlement history
|
|
180
|
+
*
|
|
181
|
+
* Get the balance and usage history of a metered entitlement. The queried range
|
|
182
|
+
* may span multiple usage periods.
|
|
183
|
+
*
|
|
184
|
+
* `windowed_history` groups usage into windows of the requested size and reports
|
|
185
|
+
* the balance at the start of each window. `burndown_history` lists the periods in
|
|
186
|
+
* which grants were consumed in a fixed order, together with the usage taken from
|
|
187
|
+
* each grant.
|
|
188
|
+
*
|
|
189
|
+
* GET /openmeter/customers/{customerId}/entitlements/{entitlementId}/history
|
|
190
|
+
*/
|
|
191
|
+
async getHistory(request, options) {
|
|
192
|
+
return unwrap(await getCustomerEntitlementHistory(this._client, request, options));
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Get customer entitlement
|
|
196
|
+
*
|
|
197
|
+
* Get an entitlement of the customer by ID. For checking entitlement access, use
|
|
198
|
+
* the entitlement access endpoints instead.
|
|
199
|
+
*
|
|
200
|
+
* GET /openmeter/customers/{customerId}/entitlements/{entitlementId}
|
|
201
|
+
*/
|
|
202
|
+
async get(request, options) {
|
|
203
|
+
return unwrap(await getCustomerEntitlement(this._client, request, options));
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* List customer entitlements
|
|
207
|
+
*
|
|
208
|
+
* List the entitlements of the customer that are active at the time of the
|
|
209
|
+
* request. For checking entitlement access, use the entitlement access endpoints
|
|
210
|
+
* instead.
|
|
211
|
+
*
|
|
212
|
+
* GET /openmeter/customers/{customerId}/entitlements
|
|
213
|
+
*/
|
|
214
|
+
async list(request, options) {
|
|
215
|
+
return unwrap(await listCustomerEntitlements(this._client, request, options));
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* List customer entitlements
|
|
219
|
+
*
|
|
220
|
+
* List the entitlements of the customer that are active at the time of the
|
|
221
|
+
* request. For checking entitlement access, use the entitlement access endpoints
|
|
222
|
+
* instead.
|
|
223
|
+
*
|
|
224
|
+
* Iterates every item across all pages, fetching more as the returned iterable is consumed.
|
|
225
|
+
*
|
|
226
|
+
* GET /openmeter/customers/{customerId}/entitlements
|
|
227
|
+
*/
|
|
228
|
+
listAll(request, options) {
|
|
229
|
+
return paginatePages((req, opts) => listCustomerEntitlements(this._client, req, opts), request, options);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Reset customer entitlement usage
|
|
233
|
+
*
|
|
234
|
+
* Reset the usage of a metered entitlement. The reset starts a new usage period:
|
|
235
|
+
* usage is zeroed and grants roll over according to their rollover settings.
|
|
236
|
+
*
|
|
237
|
+
* Usage is reset automatically at the end of each usage period. Use this operation
|
|
238
|
+
* to reset it earlier, for example to align the entitlement with the customer's
|
|
239
|
+
* billing period. The usage period anchor can be moved at the same time.
|
|
240
|
+
*
|
|
241
|
+
* POST /openmeter/customers/{customerId}/entitlements/{entitlementId}/reset
|
|
242
|
+
*/
|
|
243
|
+
async resetUsage(request, options) {
|
|
244
|
+
return unwrap(await resetCustomerEntitlementUsage(this._client, request, options));
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Delete customer entitlement
|
|
248
|
+
*
|
|
249
|
+
* Deletes the entitlement and revokes access to its feature. A customer can hold
|
|
250
|
+
* only one active entitlement per feature, so migrating a feature requires
|
|
251
|
+
* deleting the previous entitlement first.
|
|
252
|
+
*
|
|
253
|
+
* Deletion sets the `deleted_at` timestamp instead of removing history. Access and
|
|
254
|
+
* status queries for earlier points in time still treat the entitlement as active,
|
|
255
|
+
* so access changes are never retroactive.
|
|
256
|
+
*
|
|
257
|
+
* DELETE /openmeter/customers/{customerId}/entitlements/{entitlementId}
|
|
258
|
+
*/
|
|
259
|
+
async delete(request, options) {
|
|
260
|
+
return unwrap(await deleteCustomerEntitlement(this._client, request, options));
|
|
261
|
+
}
|
|
262
|
+
_grants;
|
|
263
|
+
get grants() {
|
|
264
|
+
return (this._grants ??= new CustomersEntitlementsGrants(this._client));
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
export class CustomersEntitlementsGrants {
|
|
268
|
+
_client;
|
|
269
|
+
constructor(_client) {
|
|
270
|
+
this._client = _client;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Create customer entitlement grant
|
|
274
|
+
*
|
|
275
|
+
* Issue a grant for a metered entitlement of the customer. Boolean and static
|
|
276
|
+
* entitlements cannot have grants, so the request is rejected for them.
|
|
277
|
+
*
|
|
278
|
+
* Grants are immutable. The amount is added to the balance from `effective_at`,
|
|
279
|
+
* which cannot be earlier than the start of the current usage period.
|
|
280
|
+
*
|
|
281
|
+
* POST /openmeter/customers/{customerId}/entitlements/{entitlementId}/grants
|
|
282
|
+
*/
|
|
283
|
+
async create(request, options) {
|
|
284
|
+
return unwrap(await createCustomerEntitlementGrant(this._client, request, options));
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* List customer entitlement grants
|
|
288
|
+
*
|
|
289
|
+
* List the grants issued for an entitlement of the customer. Grants only exist for
|
|
290
|
+
* metered entitlements, so the list is empty for boolean and static entitlements.
|
|
291
|
+
*
|
|
292
|
+
* Deleted grants are excluded unless `include_deleted` is set. Voided and expired
|
|
293
|
+
* grants are always included, as they are part of the balance history.
|
|
294
|
+
*
|
|
295
|
+
* GET /openmeter/customers/{customerId}/entitlements/{entitlementId}/grants
|
|
296
|
+
*/
|
|
297
|
+
async list(request, options) {
|
|
298
|
+
return unwrap(await listCustomerEntitlementGrants(this._client, request, options));
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* List customer entitlement grants
|
|
302
|
+
*
|
|
303
|
+
* List the grants issued for an entitlement of the customer. Grants only exist for
|
|
304
|
+
* metered entitlements, so the list is empty for boolean and static entitlements.
|
|
305
|
+
*
|
|
306
|
+
* Deleted grants are excluded unless `include_deleted` is set. Voided and expired
|
|
307
|
+
* grants are always included, as they are part of the balance history.
|
|
308
|
+
*
|
|
309
|
+
* Iterates every item across all pages, fetching more as the returned iterable is consumed.
|
|
310
|
+
*
|
|
311
|
+
* GET /openmeter/customers/{customerId}/entitlements/{entitlementId}/grants
|
|
312
|
+
*/
|
|
313
|
+
listAll(request, options) {
|
|
314
|
+
return paginatePages((req, opts) => listCustomerEntitlementGrants(this._client, req, opts), request, options);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
134
317
|
export class CustomersCredits {
|
|
135
318
|
_client;
|
|
136
319
|
constructor(_client) {
|
|
@@ -201,6 +384,24 @@ export class CustomersCreditsGrants {
|
|
|
201
384
|
listAll(request, options) {
|
|
202
385
|
return paginatePages((req, opts) => listCreditGrants(this._client, req, opts), request, options);
|
|
203
386
|
}
|
|
387
|
+
/**
|
|
388
|
+
* Void credit grant
|
|
389
|
+
*
|
|
390
|
+
* Void a credit grant, forfeiting the remaining unused balance.
|
|
391
|
+
*
|
|
392
|
+
* Voiding is a forward-looking, irreversible operation. Credits already consumed
|
|
393
|
+
* by usage remain unaffected — only the remaining balance is forfeited. The grant
|
|
394
|
+
* reads as `voided` status afterwards. Payment state is not adjusted when
|
|
395
|
+
* `payment_adjustment` is `none`, so invoice-backed or externally collected
|
|
396
|
+
* payments may still collect the original amount. Only `active` grants can be
|
|
397
|
+
* voided; voiding a pending, expired, or fully consumed grant returns a conflict.
|
|
398
|
+
* Retrying a successful void is an idempotent success.
|
|
399
|
+
*
|
|
400
|
+
* POST /openmeter/customers/{customerId}/credits/grants/{creditGrantId}/void
|
|
401
|
+
*/
|
|
402
|
+
async void(request, options) {
|
|
403
|
+
return unwrap(await voidCreditGrant(this._client, request, options));
|
|
404
|
+
}
|
|
204
405
|
/**
|
|
205
406
|
* Update credit grant external settlement status
|
|
206
407
|
*
|
|
@@ -288,3 +489,47 @@ export class CustomersCreditsTransactions {
|
|
|
288
489
|
return paginateCursor((req, opts) => listCreditTransactions(this._client, req, opts), request, options);
|
|
289
490
|
}
|
|
290
491
|
}
|
|
492
|
+
export class CustomersCharges {
|
|
493
|
+
_client;
|
|
494
|
+
constructor(_client) {
|
|
495
|
+
this._client = _client;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* List customer charges
|
|
499
|
+
*
|
|
500
|
+
* List customer charges.
|
|
501
|
+
*
|
|
502
|
+
* Returns the customer's charges that are represented as either flat fee or
|
|
503
|
+
* usage-based charges.
|
|
504
|
+
*
|
|
505
|
+
* GET /openmeter/customers/{customerId}/charges
|
|
506
|
+
*/
|
|
507
|
+
async list(request, options) {
|
|
508
|
+
return unwrap(await listCustomerCharges(this._client, request, options));
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* List customer charges
|
|
512
|
+
*
|
|
513
|
+
* List customer charges.
|
|
514
|
+
*
|
|
515
|
+
* Returns the customer's charges that are represented as either flat fee or
|
|
516
|
+
* usage-based charges.
|
|
517
|
+
*
|
|
518
|
+
* Iterates every item across all pages, fetching more as the returned iterable is consumed.
|
|
519
|
+
*
|
|
520
|
+
* GET /openmeter/customers/{customerId}/charges
|
|
521
|
+
*/
|
|
522
|
+
listAll(request, options) {
|
|
523
|
+
return paginatePages((req, opts) => listCustomerCharges(this._client, req, opts), request, options);
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Create customer charge
|
|
527
|
+
*
|
|
528
|
+
* Create customer charge.
|
|
529
|
+
*
|
|
530
|
+
* POST /openmeter/customers/{customerId}/charges
|
|
531
|
+
*/
|
|
532
|
+
async create(request, options) {
|
|
533
|
+
return unwrap(await createCustomerCharges(this._client, request, options));
|
|
534
|
+
}
|
|
535
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Client } from '../core.js';
|
|
2
|
+
import { type RequestOptions } from '../lib/types.js';
|
|
3
|
+
import type { QueryEntitlementAccessRequest, QueryEntitlementAccessResponse } from '../models/operations/entitlementAccess.js';
|
|
4
|
+
export declare class EntitlementAccess {
|
|
5
|
+
private readonly _client;
|
|
6
|
+
constructor(_client: Client);
|
|
7
|
+
/**
|
|
8
|
+
* Query entitlement access
|
|
9
|
+
*
|
|
10
|
+
* Query feature access for a list of customers.
|
|
11
|
+
*
|
|
12
|
+
* The endpoint resolves each provided identifier to a customer and returns the
|
|
13
|
+
* access status for the requested features, plus optional credit balance
|
|
14
|
+
* availability.
|
|
15
|
+
*
|
|
16
|
+
* _Designed to be called on a fixed refresh interval and the query response is
|
|
17
|
+
* intended to be cached._
|
|
18
|
+
*
|
|
19
|
+
* POST /openmeter/entitlement-access/query
|
|
20
|
+
*/
|
|
21
|
+
query(request: QueryEntitlementAccessRequest, options?: RequestOptions): Promise<QueryEntitlementAccessResponse>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
|
|
2
|
+
import { unwrap } from '../lib/types.js';
|
|
3
|
+
import { queryEntitlementAccess } from '../funcs/entitlementAccess.js';
|
|
4
|
+
export class EntitlementAccess {
|
|
5
|
+
_client;
|
|
6
|
+
constructor(_client) {
|
|
7
|
+
this._client = _client;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Query entitlement access
|
|
11
|
+
*
|
|
12
|
+
* Query feature access for a list of customers.
|
|
13
|
+
*
|
|
14
|
+
* The endpoint resolves each provided identifier to a customer and returns the
|
|
15
|
+
* access status for the requested features, plus optional credit balance
|
|
16
|
+
* availability.
|
|
17
|
+
*
|
|
18
|
+
* _Designed to be called on a fixed refresh interval and the query response is
|
|
19
|
+
* intended to be cached._
|
|
20
|
+
*
|
|
21
|
+
* POST /openmeter/entitlement-access/query
|
|
22
|
+
*/
|
|
23
|
+
async query(request, options) {
|
|
24
|
+
return unwrap(await queryEntitlementAccess(this._client, request, options));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Client } from '../core.js';
|
|
2
2
|
import { type RequestOptions } from '../lib/types.js';
|
|
3
|
-
import type { ListCustomerEntitlementAccessRequest, ListCustomerEntitlementAccessResponse } from '../models/operations/entitlements.js';
|
|
3
|
+
import type { ListCustomerEntitlementAccessRequest, ListCustomerEntitlementAccessResponse, GetCustomerEntitlementAccessRequest, GetCustomerEntitlementAccessResponse, GetCustomerEntitlementValueByFeatureKeyRequest, GetCustomerEntitlementValueByFeatureKeyResponse, ListEntitlementsRequest, ListEntitlementsResponse, GetEntitlementRequest, GetEntitlementResponse, GetCustomerEntitlementValueRequest, GetCustomerEntitlementValueResponse } from '../models/operations/entitlements.js';
|
|
4
|
+
import type { Entitlement } from '../models/types.js';
|
|
4
5
|
export declare class Entitlements {
|
|
5
6
|
private readonly _client;
|
|
6
7
|
constructor(_client: Client);
|
|
@@ -10,4 +11,61 @@ export declare class Entitlements {
|
|
|
10
11
|
* GET /openmeter/customers/{customerId}/entitlement-access
|
|
11
12
|
*/
|
|
12
13
|
listCustomerAccess(request: ListCustomerEntitlementAccessRequest, options?: RequestOptions): Promise<ListCustomerEntitlementAccessResponse>;
|
|
14
|
+
/**
|
|
15
|
+
* Get customer entitlement access
|
|
16
|
+
*
|
|
17
|
+
* Get the customer's access to a single feature.
|
|
18
|
+
*
|
|
19
|
+
* GET /openmeter/customers/{customerId}/entitlement-access/features/{featureKey}
|
|
20
|
+
*/
|
|
21
|
+
getCustomerAccess(request: GetCustomerEntitlementAccessRequest, options?: RequestOptions): Promise<GetCustomerEntitlementAccessResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Get customer entitlement value by feature key
|
|
24
|
+
*
|
|
25
|
+
* Get the customer's entitlement value for a feature at a point in time. Without
|
|
26
|
+
* an active entitlement, the result denies access and omits the type.
|
|
27
|
+
*
|
|
28
|
+
* GET /openmeter/customers/{customerId}/entitlement-access/features/{featureKey}/value
|
|
29
|
+
*/
|
|
30
|
+
getCustomerValueByFeatureKey(request: GetCustomerEntitlementValueByFeatureKeyRequest, options?: RequestOptions): Promise<GetCustomerEntitlementValueByFeatureKeyResponse>;
|
|
31
|
+
/**
|
|
32
|
+
* List entitlements
|
|
33
|
+
*
|
|
34
|
+
* List the active entitlements of all customers. Intended for administrative use.
|
|
35
|
+
* To list the entitlements of a single customer, use the customer entitlements
|
|
36
|
+
* endpoints; to check entitlement access, use the entitlement access endpoints.
|
|
37
|
+
*
|
|
38
|
+
* GET /openmeter/entitlements
|
|
39
|
+
*/
|
|
40
|
+
list(request?: ListEntitlementsRequest, options?: RequestOptions): Promise<ListEntitlementsResponse>;
|
|
41
|
+
/**
|
|
42
|
+
* List entitlements
|
|
43
|
+
*
|
|
44
|
+
* List the active entitlements of all customers. Intended for administrative use.
|
|
45
|
+
* To list the entitlements of a single customer, use the customer entitlements
|
|
46
|
+
* endpoints; to check entitlement access, use the entitlement access endpoints.
|
|
47
|
+
*
|
|
48
|
+
* Iterates every item across all pages, fetching more as the returned iterable is consumed.
|
|
49
|
+
*
|
|
50
|
+
* GET /openmeter/entitlements
|
|
51
|
+
*/
|
|
52
|
+
listAll(request?: ListEntitlementsRequest, options?: RequestOptions): AsyncIterable<Entitlement>;
|
|
53
|
+
/**
|
|
54
|
+
* Get entitlement
|
|
55
|
+
*
|
|
56
|
+
* Get an entitlement by ID. To check entitlement access, use the entitlement
|
|
57
|
+
* access endpoints instead.
|
|
58
|
+
*
|
|
59
|
+
* GET /openmeter/entitlements/{entitlementId}
|
|
60
|
+
*/
|
|
61
|
+
get(request: GetEntitlementRequest, options?: RequestOptions): Promise<GetEntitlementResponse>;
|
|
62
|
+
/**
|
|
63
|
+
* Get customer entitlement value
|
|
64
|
+
*
|
|
65
|
+
* Get the customer's access through a single entitlement, optionally evaluated at
|
|
66
|
+
* a point in time.
|
|
67
|
+
*
|
|
68
|
+
* GET /openmeter/customers/{customerId}/entitlements/{entitlementId}/value
|
|
69
|
+
*/
|
|
70
|
+
getCustomerValue(request: GetCustomerEntitlementValueRequest, options?: RequestOptions): Promise<GetCustomerEntitlementValueResponse>;
|
|
13
71
|
}
|
package/dist/sdk/entitlements.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
|
|
2
2
|
import { unwrap } from '../lib/types.js';
|
|
3
|
-
import {
|
|
3
|
+
import { paginatePages } from '../lib/paginate.js';
|
|
4
|
+
import { listCustomerEntitlementAccess, getCustomerEntitlementAccess, getCustomerEntitlementValueByFeatureKey, listEntitlements, getEntitlement, getCustomerEntitlementValue, } from '../funcs/entitlements.js';
|
|
4
5
|
export class Entitlements {
|
|
5
6
|
_client;
|
|
6
7
|
constructor(_client) {
|
|
@@ -14,4 +15,73 @@ export class Entitlements {
|
|
|
14
15
|
async listCustomerAccess(request, options) {
|
|
15
16
|
return unwrap(await listCustomerEntitlementAccess(this._client, request, options));
|
|
16
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Get customer entitlement access
|
|
20
|
+
*
|
|
21
|
+
* Get the customer's access to a single feature.
|
|
22
|
+
*
|
|
23
|
+
* GET /openmeter/customers/{customerId}/entitlement-access/features/{featureKey}
|
|
24
|
+
*/
|
|
25
|
+
async getCustomerAccess(request, options) {
|
|
26
|
+
return unwrap(await getCustomerEntitlementAccess(this._client, request, options));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get customer entitlement value by feature key
|
|
30
|
+
*
|
|
31
|
+
* Get the customer's entitlement value for a feature at a point in time. Without
|
|
32
|
+
* an active entitlement, the result denies access and omits the type.
|
|
33
|
+
*
|
|
34
|
+
* GET /openmeter/customers/{customerId}/entitlement-access/features/{featureKey}/value
|
|
35
|
+
*/
|
|
36
|
+
async getCustomerValueByFeatureKey(request, options) {
|
|
37
|
+
return unwrap(await getCustomerEntitlementValueByFeatureKey(this._client, request, options));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* List entitlements
|
|
41
|
+
*
|
|
42
|
+
* List the active entitlements of all customers. Intended for administrative use.
|
|
43
|
+
* To list the entitlements of a single customer, use the customer entitlements
|
|
44
|
+
* endpoints; to check entitlement access, use the entitlement access endpoints.
|
|
45
|
+
*
|
|
46
|
+
* GET /openmeter/entitlements
|
|
47
|
+
*/
|
|
48
|
+
async list(request, options) {
|
|
49
|
+
return unwrap(await listEntitlements(this._client, request, options));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* List entitlements
|
|
53
|
+
*
|
|
54
|
+
* List the active entitlements of all customers. Intended for administrative use.
|
|
55
|
+
* To list the entitlements of a single customer, use the customer entitlements
|
|
56
|
+
* endpoints; to check entitlement access, use the entitlement access endpoints.
|
|
57
|
+
*
|
|
58
|
+
* Iterates every item across all pages, fetching more as the returned iterable is consumed.
|
|
59
|
+
*
|
|
60
|
+
* GET /openmeter/entitlements
|
|
61
|
+
*/
|
|
62
|
+
listAll(request, options) {
|
|
63
|
+
return paginatePages((req, opts) => listEntitlements(this._client, req, opts), request ?? {}, options);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get entitlement
|
|
67
|
+
*
|
|
68
|
+
* Get an entitlement by ID. To check entitlement access, use the entitlement
|
|
69
|
+
* access endpoints instead.
|
|
70
|
+
*
|
|
71
|
+
* GET /openmeter/entitlements/{entitlementId}
|
|
72
|
+
*/
|
|
73
|
+
async get(request, options) {
|
|
74
|
+
return unwrap(await getEntitlement(this._client, request, options));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get customer entitlement value
|
|
78
|
+
*
|
|
79
|
+
* Get the customer's access through a single entitlement, optionally evaluated at
|
|
80
|
+
* a point in time.
|
|
81
|
+
*
|
|
82
|
+
* GET /openmeter/customers/{customerId}/entitlements/{entitlementId}/value
|
|
83
|
+
*/
|
|
84
|
+
async getCustomerValue(request, options) {
|
|
85
|
+
return unwrap(await getCustomerEntitlementValue(this._client, request, options));
|
|
86
|
+
}
|
|
17
87
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type Client } from '../core.js';
|
|
2
|
+
import { type RequestOptions } from '../lib/types.js';
|
|
3
|
+
import type { ListGrantsRequest, ListGrantsResponse, VoidGrantRequest, VoidGrantResponse } from '../models/operations/grants.js';
|
|
4
|
+
import type { EntitlementGrant } from '../models/types.js';
|
|
5
|
+
export declare class Grants {
|
|
6
|
+
private readonly _client;
|
|
7
|
+
constructor(_client: Client);
|
|
8
|
+
/**
|
|
9
|
+
* List grants
|
|
10
|
+
*
|
|
11
|
+
* List the grants of all customers and entitlements. To list the grants of a
|
|
12
|
+
* single entitlement, use the customer entitlement grants endpoint.
|
|
13
|
+
*
|
|
14
|
+
* Deleted grants are excluded unless `include_deleted` is set. Voided and expired
|
|
15
|
+
* grants are always included, as they are part of the balance history.
|
|
16
|
+
*
|
|
17
|
+
* GET /openmeter/grants
|
|
18
|
+
*/
|
|
19
|
+
list(request?: ListGrantsRequest, options?: RequestOptions): Promise<ListGrantsResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* List grants
|
|
22
|
+
*
|
|
23
|
+
* List the grants of all customers and entitlements. To list the grants of a
|
|
24
|
+
* single entitlement, use the customer entitlement grants endpoint.
|
|
25
|
+
*
|
|
26
|
+
* Deleted grants are excluded unless `include_deleted` is set. Voided and expired
|
|
27
|
+
* grants are always included, as they are part of the balance history.
|
|
28
|
+
*
|
|
29
|
+
* Iterates every item across all pages, fetching more as the returned iterable is consumed.
|
|
30
|
+
*
|
|
31
|
+
* GET /openmeter/grants
|
|
32
|
+
*/
|
|
33
|
+
listAll(request?: ListGrantsRequest, options?: RequestOptions): AsyncIterable<EntitlementGrant>;
|
|
34
|
+
/**
|
|
35
|
+
* Void grant
|
|
36
|
+
*
|
|
37
|
+
* Void a grant so it no longer adds to the balance. Usage already deducted from
|
|
38
|
+
* the grant is kept.
|
|
39
|
+
*
|
|
40
|
+
* DELETE /openmeter/grants/{grantId}
|
|
41
|
+
*/
|
|
42
|
+
void(request: VoidGrantRequest, options?: RequestOptions): Promise<VoidGrantResponse>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
|
|
2
|
+
import { unwrap } from '../lib/types.js';
|
|
3
|
+
import { paginatePages } from '../lib/paginate.js';
|
|
4
|
+
import { listGrants, voidGrant } from '../funcs/grants.js';
|
|
5
|
+
export class Grants {
|
|
6
|
+
_client;
|
|
7
|
+
constructor(_client) {
|
|
8
|
+
this._client = _client;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* List grants
|
|
12
|
+
*
|
|
13
|
+
* List the grants of all customers and entitlements. To list the grants of a
|
|
14
|
+
* single entitlement, use the customer entitlement grants endpoint.
|
|
15
|
+
*
|
|
16
|
+
* Deleted grants are excluded unless `include_deleted` is set. Voided and expired
|
|
17
|
+
* grants are always included, as they are part of the balance history.
|
|
18
|
+
*
|
|
19
|
+
* GET /openmeter/grants
|
|
20
|
+
*/
|
|
21
|
+
async list(request, options) {
|
|
22
|
+
return unwrap(await listGrants(this._client, request, options));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* List grants
|
|
26
|
+
*
|
|
27
|
+
* List the grants of all customers and entitlements. To list the grants of a
|
|
28
|
+
* single entitlement, use the customer entitlement grants endpoint.
|
|
29
|
+
*
|
|
30
|
+
* Deleted grants are excluded unless `include_deleted` is set. Voided and expired
|
|
31
|
+
* grants are always included, as they are part of the balance history.
|
|
32
|
+
*
|
|
33
|
+
* Iterates every item across all pages, fetching more as the returned iterable is consumed.
|
|
34
|
+
*
|
|
35
|
+
* GET /openmeter/grants
|
|
36
|
+
*/
|
|
37
|
+
listAll(request, options) {
|
|
38
|
+
return paginatePages((req, opts) => listGrants(this._client, req, opts), request ?? {}, options);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Void grant
|
|
42
|
+
*
|
|
43
|
+
* Void a grant so it no longer adds to the balance. Usage already deducted from
|
|
44
|
+
* the grant is kept.
|
|
45
|
+
*
|
|
46
|
+
* DELETE /openmeter/grants/{grantId}
|
|
47
|
+
*/
|
|
48
|
+
async void(request, options) {
|
|
49
|
+
return unwrap(await voidGrant(this._client, request, options));
|
|
50
|
+
}
|
|
51
|
+
}
|