@openmeter/client 1.0.0-beta.233 → 1.0.0-beta.235
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 -111
- package/dist/funcs/customers.d.ts +112 -1
- package/dist/funcs/customers.js +430 -0
- package/dist/funcs/entitlements.d.ts +38 -1
- package/dist/funcs/entitlements.js +169 -6
- package/dist/funcs/grants.d.ts +24 -0
- package/dist/funcs/grants.js +78 -0
- package/dist/funcs/index.d.ts +2 -0
- package/dist/funcs/index.js +2 -0
- package/dist/funcs/notifications.d.ts +43 -0
- package/dist/funcs/notifications.js +163 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.js +6 -0
- package/dist/lib/version.d.ts +1 -1
- package/dist/lib/version.js +1 -1
- package/dist/models/operations/customers.d.ts +109 -1
- package/dist/models/operations/entitlements.d.ts +59 -4
- package/dist/models/operations/grants.d.ts +43 -0
- package/dist/models/operations/grants.js +2 -0
- package/dist/models/operations/notifications.d.ts +46 -0
- package/dist/models/operations/notifications.js +2 -0
- package/dist/models/schemas.d.ts +6556 -2713
- package/dist/models/schemas.js +1802 -365
- package/dist/models/types.d.ts +1177 -228
- package/dist/sdk/apps.d.ts +70 -1
- package/dist/sdk/apps.js +86 -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 +51 -1
- package/dist/sdk/entitlements.js +61 -1
- package/dist/sdk/grants.d.ts +43 -0
- package/dist/sdk/grants.js +51 -0
- package/dist/sdk/internal.d.ts +5 -458
- package/dist/sdk/internal.js +6 -569
- package/dist/sdk/notifications.d.ts +58 -0
- package/dist/sdk/notifications.js +72 -0
- 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 -9
- package/dist/sdk/subscriptions.js +45 -11
- package/package.json +1 -1
package/dist/funcs/customers.js
CHANGED
|
@@ -351,6 +351,436 @@ export function createCustomerStripePortalSession(client, req, options) {
|
|
|
351
351
|
});
|
|
352
352
|
});
|
|
353
353
|
}
|
|
354
|
+
/**
|
|
355
|
+
* Create customer entitlement
|
|
356
|
+
*
|
|
357
|
+
* Create an entitlement for the customer.
|
|
358
|
+
*
|
|
359
|
+
* A customer can have only one active entitlement per feature. The feature must be
|
|
360
|
+
* compatible with the entitlement type. Entitlements cannot be modified after
|
|
361
|
+
* creation, only deleted.
|
|
362
|
+
*
|
|
363
|
+
* POST /openmeter/customers/{customerId}/entitlements
|
|
364
|
+
*/
|
|
365
|
+
export function createCustomerEntitlement(client, req, options) {
|
|
366
|
+
return request(() => {
|
|
367
|
+
const pathParamsInput = {
|
|
368
|
+
customerId: req.customerId,
|
|
369
|
+
};
|
|
370
|
+
const pathParams = client._options.validate
|
|
371
|
+
? toPathWire(pathParamsInput, schemas.createCustomerEntitlementPathParams)
|
|
372
|
+
: pathParamsInput;
|
|
373
|
+
if (client._options.validate) {
|
|
374
|
+
assertValid(schemas.createCustomerEntitlementPathParamsWire, pathParams);
|
|
375
|
+
}
|
|
376
|
+
const path = `openmeter/customers/${(() => {
|
|
377
|
+
if (pathParams.customerId === undefined) {
|
|
378
|
+
throw new Error('missing path parameter: customerId');
|
|
379
|
+
}
|
|
380
|
+
return encodeURIComponent(String(pathParams.customerId));
|
|
381
|
+
})()}/entitlements`;
|
|
382
|
+
const body = toWire(req.body, schemas.createCustomerEntitlementBody);
|
|
383
|
+
if (client._options.validate) {
|
|
384
|
+
assertValid(schemas.createCustomerEntitlementBodyWire, body);
|
|
385
|
+
}
|
|
386
|
+
return http(client)
|
|
387
|
+
.post(path, { ...options, json: body })
|
|
388
|
+
.json()
|
|
389
|
+
.then((data) => {
|
|
390
|
+
if (client._options.validate) {
|
|
391
|
+
assertValid(schemas.createCustomerEntitlementResponseWire, data);
|
|
392
|
+
}
|
|
393
|
+
return fromWire(data, schemas.createCustomerEntitlementResponse);
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Override customer entitlement
|
|
399
|
+
*
|
|
400
|
+
* Override an entitlement of the customer with a new one.
|
|
401
|
+
*
|
|
402
|
+
* The referenced entitlement ends and the new one starts at the same instant, so
|
|
403
|
+
* access continues without a gap. Both must belong to the same feature. Use this
|
|
404
|
+
* for upgrades and downgrades.
|
|
405
|
+
*
|
|
406
|
+
* Fails if the referenced entitlement does not exist, is deleted, or is no longer
|
|
407
|
+
* active.
|
|
408
|
+
*
|
|
409
|
+
* PUT /openmeter/customers/{customerId}/entitlements/{entitlementId}/override
|
|
410
|
+
*/
|
|
411
|
+
export function overrideCustomerEntitlement(client, req, options) {
|
|
412
|
+
return request(() => {
|
|
413
|
+
const pathParamsInput = {
|
|
414
|
+
customerId: req.customerId,
|
|
415
|
+
entitlementId: req.entitlementId,
|
|
416
|
+
};
|
|
417
|
+
const pathParams = client._options.validate
|
|
418
|
+
? toPathWire(pathParamsInput, schemas.overrideCustomerEntitlementPathParams)
|
|
419
|
+
: pathParamsInput;
|
|
420
|
+
if (client._options.validate) {
|
|
421
|
+
assertValid(schemas.overrideCustomerEntitlementPathParamsWire, pathParams);
|
|
422
|
+
}
|
|
423
|
+
const path = `openmeter/customers/${(() => {
|
|
424
|
+
if (pathParams.customerId === undefined) {
|
|
425
|
+
throw new Error('missing path parameter: customerId');
|
|
426
|
+
}
|
|
427
|
+
return encodeURIComponent(String(pathParams.customerId));
|
|
428
|
+
})()}/entitlements/${(() => {
|
|
429
|
+
if (pathParams.entitlementId === undefined) {
|
|
430
|
+
throw new Error('missing path parameter: entitlementId');
|
|
431
|
+
}
|
|
432
|
+
return encodeURIComponent(String(pathParams.entitlementId));
|
|
433
|
+
})()}/override`;
|
|
434
|
+
const body = toWire(req.body, schemas.overrideCustomerEntitlementBody);
|
|
435
|
+
if (client._options.validate) {
|
|
436
|
+
assertValid(schemas.overrideCustomerEntitlementBodyWire, body);
|
|
437
|
+
}
|
|
438
|
+
return http(client)
|
|
439
|
+
.put(path, { ...options, json: body })
|
|
440
|
+
.json()
|
|
441
|
+
.then((data) => {
|
|
442
|
+
if (client._options.validate) {
|
|
443
|
+
assertValid(schemas.overrideCustomerEntitlementResponseWire, data);
|
|
444
|
+
}
|
|
445
|
+
return fromWire(data, schemas.overrideCustomerEntitlementResponse);
|
|
446
|
+
});
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Get customer entitlement history
|
|
451
|
+
*
|
|
452
|
+
* Get the balance and usage history of a metered entitlement. The queried range
|
|
453
|
+
* may span multiple usage periods.
|
|
454
|
+
*
|
|
455
|
+
* `windowed_history` groups usage into windows of the requested size and reports
|
|
456
|
+
* the balance at the start of each window. `burndown_history` lists the periods in
|
|
457
|
+
* which grants were consumed in a fixed order, together with the usage taken from
|
|
458
|
+
* each grant.
|
|
459
|
+
*
|
|
460
|
+
* GET /openmeter/customers/{customerId}/entitlements/{entitlementId}/history
|
|
461
|
+
*/
|
|
462
|
+
export function getCustomerEntitlementHistory(client, req, options) {
|
|
463
|
+
return request(() => {
|
|
464
|
+
const pathParamsInput = {
|
|
465
|
+
customerId: req.customerId,
|
|
466
|
+
entitlementId: req.entitlementId,
|
|
467
|
+
};
|
|
468
|
+
const pathParams = client._options.validate
|
|
469
|
+
? toPathWire(pathParamsInput, schemas.getCustomerEntitlementHistoryPathParams)
|
|
470
|
+
: pathParamsInput;
|
|
471
|
+
if (client._options.validate) {
|
|
472
|
+
assertValid(schemas.getCustomerEntitlementHistoryPathParamsWire, pathParams);
|
|
473
|
+
}
|
|
474
|
+
const path = `openmeter/customers/${(() => {
|
|
475
|
+
if (pathParams.customerId === undefined) {
|
|
476
|
+
throw new Error('missing path parameter: customerId');
|
|
477
|
+
}
|
|
478
|
+
return encodeURIComponent(String(pathParams.customerId));
|
|
479
|
+
})()}/entitlements/${(() => {
|
|
480
|
+
if (pathParams.entitlementId === undefined) {
|
|
481
|
+
throw new Error('missing path parameter: entitlementId');
|
|
482
|
+
}
|
|
483
|
+
return encodeURIComponent(String(pathParams.entitlementId));
|
|
484
|
+
})()}/history`;
|
|
485
|
+
const query = toWire({
|
|
486
|
+
from: req.from,
|
|
487
|
+
to: req.to,
|
|
488
|
+
windowSize: req.windowSize,
|
|
489
|
+
timeZone: req.timeZone,
|
|
490
|
+
}, schemas.getCustomerEntitlementHistoryQueryParams);
|
|
491
|
+
if (client._options.validate) {
|
|
492
|
+
assertValid(schemas.getCustomerEntitlementHistoryQueryParamsWire, query);
|
|
493
|
+
}
|
|
494
|
+
const searchParams = toURLSearchParams(query);
|
|
495
|
+
return http(client)
|
|
496
|
+
.get(path, { ...options, searchParams })
|
|
497
|
+
.json()
|
|
498
|
+
.then((data) => {
|
|
499
|
+
if (client._options.validate) {
|
|
500
|
+
assertValid(schemas.getCustomerEntitlementHistoryResponseWire, data);
|
|
501
|
+
}
|
|
502
|
+
return fromWire(data, schemas.getCustomerEntitlementHistoryResponse);
|
|
503
|
+
});
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Get customer entitlement
|
|
508
|
+
*
|
|
509
|
+
* Get an entitlement of the customer by ID. For checking entitlement access, use
|
|
510
|
+
* the entitlement access endpoints instead.
|
|
511
|
+
*
|
|
512
|
+
* GET /openmeter/customers/{customerId}/entitlements/{entitlementId}
|
|
513
|
+
*/
|
|
514
|
+
export function getCustomerEntitlement(client, req, options) {
|
|
515
|
+
return request(() => {
|
|
516
|
+
const pathParamsInput = {
|
|
517
|
+
customerId: req.customerId,
|
|
518
|
+
entitlementId: req.entitlementId,
|
|
519
|
+
};
|
|
520
|
+
const pathParams = client._options.validate
|
|
521
|
+
? toPathWire(pathParamsInput, schemas.getCustomerEntitlementPathParams)
|
|
522
|
+
: pathParamsInput;
|
|
523
|
+
if (client._options.validate) {
|
|
524
|
+
assertValid(schemas.getCustomerEntitlementPathParamsWire, pathParams);
|
|
525
|
+
}
|
|
526
|
+
const path = `openmeter/customers/${(() => {
|
|
527
|
+
if (pathParams.customerId === undefined) {
|
|
528
|
+
throw new Error('missing path parameter: customerId');
|
|
529
|
+
}
|
|
530
|
+
return encodeURIComponent(String(pathParams.customerId));
|
|
531
|
+
})()}/entitlements/${(() => {
|
|
532
|
+
if (pathParams.entitlementId === undefined) {
|
|
533
|
+
throw new Error('missing path parameter: entitlementId');
|
|
534
|
+
}
|
|
535
|
+
return encodeURIComponent(String(pathParams.entitlementId));
|
|
536
|
+
})()}`;
|
|
537
|
+
return http(client)
|
|
538
|
+
.get(path, options)
|
|
539
|
+
.json()
|
|
540
|
+
.then((data) => {
|
|
541
|
+
if (client._options.validate) {
|
|
542
|
+
assertValid(schemas.getCustomerEntitlementResponseWire, data);
|
|
543
|
+
}
|
|
544
|
+
return fromWire(data, schemas.getCustomerEntitlementResponse);
|
|
545
|
+
});
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* List customer entitlements
|
|
550
|
+
*
|
|
551
|
+
* List the entitlements of the customer that are active at the time of the
|
|
552
|
+
* request. For checking entitlement access, use the entitlement access endpoints
|
|
553
|
+
* instead.
|
|
554
|
+
*
|
|
555
|
+
* GET /openmeter/customers/{customerId}/entitlements
|
|
556
|
+
*/
|
|
557
|
+
export function listCustomerEntitlements(client, req, options) {
|
|
558
|
+
return request(() => {
|
|
559
|
+
const pathParamsInput = {
|
|
560
|
+
customerId: req.customerId,
|
|
561
|
+
};
|
|
562
|
+
const pathParams = client._options.validate
|
|
563
|
+
? toPathWire(pathParamsInput, schemas.listCustomerEntitlementsPathParams)
|
|
564
|
+
: pathParamsInput;
|
|
565
|
+
if (client._options.validate) {
|
|
566
|
+
assertValid(schemas.listCustomerEntitlementsPathParamsWire, pathParams);
|
|
567
|
+
}
|
|
568
|
+
const path = `openmeter/customers/${(() => {
|
|
569
|
+
if (pathParams.customerId === undefined) {
|
|
570
|
+
throw new Error('missing path parameter: customerId');
|
|
571
|
+
}
|
|
572
|
+
return encodeURIComponent(String(pathParams.customerId));
|
|
573
|
+
})()}/entitlements`;
|
|
574
|
+
if (client._options.validate && req.sort !== undefined) {
|
|
575
|
+
assertValid(schemas.listCustomerEntitlementsQueryParams.shape.sort, req.sort);
|
|
576
|
+
}
|
|
577
|
+
const query = toWire({
|
|
578
|
+
page: req.page,
|
|
579
|
+
sort: encodeSort(req.sort, toSnakeCase),
|
|
580
|
+
filter: req.filter,
|
|
581
|
+
}, schemas.listCustomerEntitlementsQueryParams);
|
|
582
|
+
if (client._options.validate) {
|
|
583
|
+
assertValid(schemas.listCustomerEntitlementsQueryParamsWire, query);
|
|
584
|
+
}
|
|
585
|
+
const searchParams = toURLSearchParams(query);
|
|
586
|
+
return http(client)
|
|
587
|
+
.get(path, { ...options, searchParams })
|
|
588
|
+
.json()
|
|
589
|
+
.then((data) => {
|
|
590
|
+
if (client._options.validate) {
|
|
591
|
+
assertValid(schemas.listCustomerEntitlementsResponseWire, data);
|
|
592
|
+
}
|
|
593
|
+
return fromWire(data, schemas.listCustomerEntitlementsResponse);
|
|
594
|
+
});
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Reset customer entitlement usage
|
|
599
|
+
*
|
|
600
|
+
* Reset the usage of a metered entitlement. The reset starts a new usage period:
|
|
601
|
+
* usage is zeroed and grants roll over according to their rollover settings.
|
|
602
|
+
*
|
|
603
|
+
* Usage is reset automatically at the end of each usage period. Use this operation
|
|
604
|
+
* to reset it earlier, for example to align the entitlement with the customer's
|
|
605
|
+
* billing period. The usage period anchor can be moved at the same time.
|
|
606
|
+
*
|
|
607
|
+
* POST /openmeter/customers/{customerId}/entitlements/{entitlementId}/reset
|
|
608
|
+
*/
|
|
609
|
+
export function resetCustomerEntitlementUsage(client, req, options) {
|
|
610
|
+
return request(async () => {
|
|
611
|
+
const pathParamsInput = {
|
|
612
|
+
customerId: req.customerId,
|
|
613
|
+
entitlementId: req.entitlementId,
|
|
614
|
+
};
|
|
615
|
+
const pathParams = client._options.validate
|
|
616
|
+
? toPathWire(pathParamsInput, schemas.resetCustomerEntitlementUsagePathParams)
|
|
617
|
+
: pathParamsInput;
|
|
618
|
+
if (client._options.validate) {
|
|
619
|
+
assertValid(schemas.resetCustomerEntitlementUsagePathParamsWire, pathParams);
|
|
620
|
+
}
|
|
621
|
+
const path = `openmeter/customers/${(() => {
|
|
622
|
+
if (pathParams.customerId === undefined) {
|
|
623
|
+
throw new Error('missing path parameter: customerId');
|
|
624
|
+
}
|
|
625
|
+
return encodeURIComponent(String(pathParams.customerId));
|
|
626
|
+
})()}/entitlements/${(() => {
|
|
627
|
+
if (pathParams.entitlementId === undefined) {
|
|
628
|
+
throw new Error('missing path parameter: entitlementId');
|
|
629
|
+
}
|
|
630
|
+
return encodeURIComponent(String(pathParams.entitlementId));
|
|
631
|
+
})()}/reset`;
|
|
632
|
+
const body = toWire(req.body, schemas.resetCustomerEntitlementUsageBody);
|
|
633
|
+
if (client._options.validate) {
|
|
634
|
+
assertValid(schemas.resetCustomerEntitlementUsageBodyWire, body);
|
|
635
|
+
}
|
|
636
|
+
await http(client).post(path, { ...options, json: body });
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Delete customer entitlement
|
|
641
|
+
*
|
|
642
|
+
* Deletes the entitlement and revokes access to its feature. A customer can hold
|
|
643
|
+
* only one active entitlement per feature, so migrating a feature requires
|
|
644
|
+
* deleting the previous entitlement first.
|
|
645
|
+
*
|
|
646
|
+
* Deletion sets the `deleted_at` timestamp instead of removing history. Access and
|
|
647
|
+
* status queries for earlier points in time still treat the entitlement as active,
|
|
648
|
+
* so access changes are never retroactive.
|
|
649
|
+
*
|
|
650
|
+
* DELETE /openmeter/customers/{customerId}/entitlements/{entitlementId}
|
|
651
|
+
*/
|
|
652
|
+
export function deleteCustomerEntitlement(client, req, options) {
|
|
653
|
+
return request(async () => {
|
|
654
|
+
const pathParamsInput = {
|
|
655
|
+
customerId: req.customerId,
|
|
656
|
+
entitlementId: req.entitlementId,
|
|
657
|
+
};
|
|
658
|
+
const pathParams = client._options.validate
|
|
659
|
+
? toPathWire(pathParamsInput, schemas.deleteCustomerEntitlementPathParams)
|
|
660
|
+
: pathParamsInput;
|
|
661
|
+
if (client._options.validate) {
|
|
662
|
+
assertValid(schemas.deleteCustomerEntitlementPathParamsWire, pathParams);
|
|
663
|
+
}
|
|
664
|
+
const path = `openmeter/customers/${(() => {
|
|
665
|
+
if (pathParams.customerId === undefined) {
|
|
666
|
+
throw new Error('missing path parameter: customerId');
|
|
667
|
+
}
|
|
668
|
+
return encodeURIComponent(String(pathParams.customerId));
|
|
669
|
+
})()}/entitlements/${(() => {
|
|
670
|
+
if (pathParams.entitlementId === undefined) {
|
|
671
|
+
throw new Error('missing path parameter: entitlementId');
|
|
672
|
+
}
|
|
673
|
+
return encodeURIComponent(String(pathParams.entitlementId));
|
|
674
|
+
})()}`;
|
|
675
|
+
await http(client).delete(path, options);
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Create customer entitlement grant
|
|
680
|
+
*
|
|
681
|
+
* Issue a grant for a metered entitlement of the customer. Boolean and static
|
|
682
|
+
* entitlements cannot have grants, so the request is rejected for them.
|
|
683
|
+
*
|
|
684
|
+
* Grants are immutable. The amount is added to the balance from `effective_at`,
|
|
685
|
+
* which cannot be earlier than the start of the current usage period.
|
|
686
|
+
*
|
|
687
|
+
* POST /openmeter/customers/{customerId}/entitlements/{entitlementId}/grants
|
|
688
|
+
*/
|
|
689
|
+
export function createCustomerEntitlementGrant(client, req, options) {
|
|
690
|
+
return request(() => {
|
|
691
|
+
const pathParamsInput = {
|
|
692
|
+
customerId: req.customerId,
|
|
693
|
+
entitlementId: req.entitlementId,
|
|
694
|
+
};
|
|
695
|
+
const pathParams = client._options.validate
|
|
696
|
+
? toPathWire(pathParamsInput, schemas.createCustomerEntitlementGrantPathParams)
|
|
697
|
+
: pathParamsInput;
|
|
698
|
+
if (client._options.validate) {
|
|
699
|
+
assertValid(schemas.createCustomerEntitlementGrantPathParamsWire, pathParams);
|
|
700
|
+
}
|
|
701
|
+
const path = `openmeter/customers/${(() => {
|
|
702
|
+
if (pathParams.customerId === undefined) {
|
|
703
|
+
throw new Error('missing path parameter: customerId');
|
|
704
|
+
}
|
|
705
|
+
return encodeURIComponent(String(pathParams.customerId));
|
|
706
|
+
})()}/entitlements/${(() => {
|
|
707
|
+
if (pathParams.entitlementId === undefined) {
|
|
708
|
+
throw new Error('missing path parameter: entitlementId');
|
|
709
|
+
}
|
|
710
|
+
return encodeURIComponent(String(pathParams.entitlementId));
|
|
711
|
+
})()}/grants`;
|
|
712
|
+
const body = toWire(req.body, schemas.createCustomerEntitlementGrantBody);
|
|
713
|
+
if (client._options.validate) {
|
|
714
|
+
assertValid(schemas.createCustomerEntitlementGrantBodyWire, body);
|
|
715
|
+
}
|
|
716
|
+
return http(client)
|
|
717
|
+
.post(path, { ...options, json: body })
|
|
718
|
+
.json()
|
|
719
|
+
.then((data) => {
|
|
720
|
+
if (client._options.validate) {
|
|
721
|
+
assertValid(schemas.createCustomerEntitlementGrantResponseWire, data);
|
|
722
|
+
}
|
|
723
|
+
return fromWire(data, schemas.createCustomerEntitlementGrantResponse);
|
|
724
|
+
});
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
/**
|
|
728
|
+
* List customer entitlement grants
|
|
729
|
+
*
|
|
730
|
+
* List the grants issued for an entitlement of the customer. Grants only exist for
|
|
731
|
+
* metered entitlements, so the list is empty for boolean and static entitlements.
|
|
732
|
+
*
|
|
733
|
+
* Deleted grants are excluded unless `include_deleted` is set. Voided and expired
|
|
734
|
+
* grants are always included, as they are part of the balance history.
|
|
735
|
+
*
|
|
736
|
+
* GET /openmeter/customers/{customerId}/entitlements/{entitlementId}/grants
|
|
737
|
+
*/
|
|
738
|
+
export function listCustomerEntitlementGrants(client, req, options) {
|
|
739
|
+
return request(() => {
|
|
740
|
+
const pathParamsInput = {
|
|
741
|
+
customerId: req.customerId,
|
|
742
|
+
entitlementId: req.entitlementId,
|
|
743
|
+
};
|
|
744
|
+
const pathParams = client._options.validate
|
|
745
|
+
? toPathWire(pathParamsInput, schemas.listCustomerEntitlementGrantsPathParams)
|
|
746
|
+
: pathParamsInput;
|
|
747
|
+
if (client._options.validate) {
|
|
748
|
+
assertValid(schemas.listCustomerEntitlementGrantsPathParamsWire, pathParams);
|
|
749
|
+
}
|
|
750
|
+
const path = `openmeter/customers/${(() => {
|
|
751
|
+
if (pathParams.customerId === undefined) {
|
|
752
|
+
throw new Error('missing path parameter: customerId');
|
|
753
|
+
}
|
|
754
|
+
return encodeURIComponent(String(pathParams.customerId));
|
|
755
|
+
})()}/entitlements/${(() => {
|
|
756
|
+
if (pathParams.entitlementId === undefined) {
|
|
757
|
+
throw new Error('missing path parameter: entitlementId');
|
|
758
|
+
}
|
|
759
|
+
return encodeURIComponent(String(pathParams.entitlementId));
|
|
760
|
+
})()}/grants`;
|
|
761
|
+
if (client._options.validate && req.sort !== undefined) {
|
|
762
|
+
assertValid(schemas.listCustomerEntitlementGrantsQueryParams.shape.sort, req.sort);
|
|
763
|
+
}
|
|
764
|
+
const query = toWire({
|
|
765
|
+
page: req.page,
|
|
766
|
+
sort: encodeSort(req.sort, toSnakeCase),
|
|
767
|
+
includeDeleted: req.includeDeleted,
|
|
768
|
+
}, schemas.listCustomerEntitlementGrantsQueryParams);
|
|
769
|
+
if (client._options.validate) {
|
|
770
|
+
assertValid(schemas.listCustomerEntitlementGrantsQueryParamsWire, query);
|
|
771
|
+
}
|
|
772
|
+
const searchParams = toURLSearchParams(query);
|
|
773
|
+
return http(client)
|
|
774
|
+
.get(path, { ...options, searchParams })
|
|
775
|
+
.json()
|
|
776
|
+
.then((data) => {
|
|
777
|
+
if (client._options.validate) {
|
|
778
|
+
assertValid(schemas.listCustomerEntitlementGrantsResponseWire, data);
|
|
779
|
+
}
|
|
780
|
+
return fromWire(data, schemas.listCustomerEntitlementGrantsResponse);
|
|
781
|
+
});
|
|
782
|
+
});
|
|
783
|
+
}
|
|
354
784
|
/**
|
|
355
785
|
* Create a new credit grant
|
|
356
786
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Client } from '../core.js';
|
|
2
2
|
import { type Result, type RequestOptions } from '../lib/types.js';
|
|
3
|
-
import type { ListCustomerEntitlementAccessRequest, ListCustomerEntitlementAccessResponse, GetCustomerEntitlementAccessRequest, GetCustomerEntitlementAccessResponse } 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
4
|
/**
|
|
5
5
|
* List customer entitlement access
|
|
6
6
|
*
|
|
@@ -15,3 +15,40 @@ export declare function listCustomerEntitlementAccess(client: Client, req: ListC
|
|
|
15
15
|
* GET /openmeter/customers/{customerId}/entitlement-access/features/{featureKey}
|
|
16
16
|
*/
|
|
17
17
|
export declare function getCustomerEntitlementAccess(client: Client, req: GetCustomerEntitlementAccessRequest, options?: RequestOptions): Promise<Result<GetCustomerEntitlementAccessResponse>>;
|
|
18
|
+
/**
|
|
19
|
+
* Get customer entitlement value by feature key
|
|
20
|
+
*
|
|
21
|
+
* Get the customer's entitlement value for a feature at a point in time. Without
|
|
22
|
+
* an active entitlement, the result denies access and omits the type.
|
|
23
|
+
*
|
|
24
|
+
* GET /openmeter/customers/{customerId}/entitlement-access/features/{featureKey}/value
|
|
25
|
+
*/
|
|
26
|
+
export declare function getCustomerEntitlementValueByFeatureKey(client: Client, req: GetCustomerEntitlementValueByFeatureKeyRequest, options?: RequestOptions): Promise<Result<GetCustomerEntitlementValueByFeatureKeyResponse>>;
|
|
27
|
+
/**
|
|
28
|
+
* List entitlements
|
|
29
|
+
*
|
|
30
|
+
* List the active entitlements of all customers. Intended for administrative use.
|
|
31
|
+
* To list the entitlements of a single customer, use the customer entitlements
|
|
32
|
+
* endpoints; to check entitlement access, use the entitlement access endpoints.
|
|
33
|
+
*
|
|
34
|
+
* GET /openmeter/entitlements
|
|
35
|
+
*/
|
|
36
|
+
export declare function listEntitlements(client: Client, req?: ListEntitlementsRequest, options?: RequestOptions): Promise<Result<ListEntitlementsResponse>>;
|
|
37
|
+
/**
|
|
38
|
+
* Get entitlement
|
|
39
|
+
*
|
|
40
|
+
* Get an entitlement by ID. To check entitlement access, use the entitlement
|
|
41
|
+
* access endpoints instead.
|
|
42
|
+
*
|
|
43
|
+
* GET /openmeter/entitlements/{entitlementId}
|
|
44
|
+
*/
|
|
45
|
+
export declare function getEntitlement(client: Client, req: GetEntitlementRequest, options?: RequestOptions): Promise<Result<GetEntitlementResponse>>;
|
|
46
|
+
/**
|
|
47
|
+
* Get customer entitlement value
|
|
48
|
+
*
|
|
49
|
+
* Get the customer's access through a single entitlement, optionally evaluated at
|
|
50
|
+
* a point in time.
|
|
51
|
+
*
|
|
52
|
+
* GET /openmeter/customers/{customerId}/entitlements/{entitlementId}/value
|
|
53
|
+
*/
|
|
54
|
+
export declare function getCustomerEntitlementValue(client: Client, req: GetCustomerEntitlementValueRequest, options?: RequestOptions): Promise<Result<GetCustomerEntitlementValueResponse>>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Code generated by @openmeter/typespec-typescript. DO NOT EDIT.
|
|
2
2
|
import { http } from '../core.js';
|
|
3
3
|
import { request } from '../lib/request.js';
|
|
4
|
-
import { toURLSearchParams } from '../lib/encodings.js';
|
|
5
|
-
import { toWire, toPathWire, fromWire, assertValid } from '../lib/wire.js';
|
|
4
|
+
import { toURLSearchParams, encodeSort } from '../lib/encodings.js';
|
|
5
|
+
import { toWire, toPathWire, fromWire, assertValid, toSnakeCase, } from '../lib/wire.js';
|
|
6
6
|
import * as schemas from '../models/schemas.js';
|
|
7
7
|
/**
|
|
8
8
|
* List customer entitlement access
|
|
@@ -67,11 +67,54 @@ export function getCustomerEntitlementAccess(client, req, options) {
|
|
|
67
67
|
}
|
|
68
68
|
return encodeURIComponent(String(pathParams.featureKey));
|
|
69
69
|
})()}`;
|
|
70
|
+
return http(client)
|
|
71
|
+
.get(path, options)
|
|
72
|
+
.json()
|
|
73
|
+
.then((data) => {
|
|
74
|
+
if (client._options.validate) {
|
|
75
|
+
assertValid(schemas.getCustomerEntitlementAccessResponseWire, data);
|
|
76
|
+
}
|
|
77
|
+
return fromWire(data, schemas.getCustomerEntitlementAccessResponse);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get customer entitlement value by feature key
|
|
83
|
+
*
|
|
84
|
+
* Get the customer's entitlement value for a feature at a point in time. Without
|
|
85
|
+
* an active entitlement, the result denies access and omits the type.
|
|
86
|
+
*
|
|
87
|
+
* GET /openmeter/customers/{customerId}/entitlement-access/features/{featureKey}/value
|
|
88
|
+
*/
|
|
89
|
+
export function getCustomerEntitlementValueByFeatureKey(client, req, options) {
|
|
90
|
+
return request(() => {
|
|
91
|
+
const pathParamsInput = {
|
|
92
|
+
customerId: req.customerId,
|
|
93
|
+
featureKey: req.featureKey,
|
|
94
|
+
};
|
|
95
|
+
const pathParams = client._options.validate
|
|
96
|
+
? toPathWire(pathParamsInput, schemas.getCustomerEntitlementValueByFeatureKeyPathParams)
|
|
97
|
+
: pathParamsInput;
|
|
98
|
+
if (client._options.validate) {
|
|
99
|
+
assertValid(schemas.getCustomerEntitlementValueByFeatureKeyPathParamsWire, pathParams);
|
|
100
|
+
}
|
|
101
|
+
const path = `openmeter/customers/${(() => {
|
|
102
|
+
if (pathParams.customerId === undefined) {
|
|
103
|
+
throw new Error('missing path parameter: customerId');
|
|
104
|
+
}
|
|
105
|
+
return encodeURIComponent(String(pathParams.customerId));
|
|
106
|
+
})()}/entitlement-access/features/${(() => {
|
|
107
|
+
if (pathParams.featureKey === undefined) {
|
|
108
|
+
throw new Error('missing path parameter: featureKey');
|
|
109
|
+
}
|
|
110
|
+
return encodeURIComponent(String(pathParams.featureKey));
|
|
111
|
+
})()}/value`;
|
|
70
112
|
const query = toWire({
|
|
71
113
|
expand: req.expand,
|
|
72
|
-
|
|
114
|
+
at: req.at,
|
|
115
|
+
}, schemas.getCustomerEntitlementValueByFeatureKeyQueryParams);
|
|
73
116
|
if (client._options.validate) {
|
|
74
|
-
assertValid(schemas.
|
|
117
|
+
assertValid(schemas.getCustomerEntitlementValueByFeatureKeyQueryParamsWire, query);
|
|
75
118
|
}
|
|
76
119
|
const searchParams = toURLSearchParams(query);
|
|
77
120
|
return http(client)
|
|
@@ -79,9 +122,129 @@ export function getCustomerEntitlementAccess(client, req, options) {
|
|
|
79
122
|
.json()
|
|
80
123
|
.then((data) => {
|
|
81
124
|
if (client._options.validate) {
|
|
82
|
-
assertValid(schemas.
|
|
125
|
+
assertValid(schemas.getCustomerEntitlementValueByFeatureKeyResponseWire, data);
|
|
83
126
|
}
|
|
84
|
-
return fromWire(data, schemas.
|
|
127
|
+
return fromWire(data, schemas.getCustomerEntitlementValueByFeatureKeyResponse);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* List entitlements
|
|
133
|
+
*
|
|
134
|
+
* List the active entitlements of all customers. Intended for administrative use.
|
|
135
|
+
* To list the entitlements of a single customer, use the customer entitlements
|
|
136
|
+
* endpoints; to check entitlement access, use the entitlement access endpoints.
|
|
137
|
+
*
|
|
138
|
+
* GET /openmeter/entitlements
|
|
139
|
+
*/
|
|
140
|
+
export function listEntitlements(client, req = {}, options) {
|
|
141
|
+
return request(() => {
|
|
142
|
+
if (client._options.validate && req.sort !== undefined) {
|
|
143
|
+
assertValid(schemas.listEntitlementsQueryParams.shape.sort, req.sort);
|
|
144
|
+
}
|
|
145
|
+
const query = toWire({
|
|
146
|
+
page: req.page,
|
|
147
|
+
sort: encodeSort(req.sort, toSnakeCase),
|
|
148
|
+
filter: req.filter,
|
|
149
|
+
}, schemas.listEntitlementsQueryParams);
|
|
150
|
+
if (client._options.validate) {
|
|
151
|
+
assertValid(schemas.listEntitlementsQueryParamsWire, query);
|
|
152
|
+
}
|
|
153
|
+
const searchParams = toURLSearchParams(query);
|
|
154
|
+
return http(client)
|
|
155
|
+
.get('openmeter/entitlements', { ...options, searchParams })
|
|
156
|
+
.json()
|
|
157
|
+
.then((data) => {
|
|
158
|
+
if (client._options.validate) {
|
|
159
|
+
assertValid(schemas.listEntitlementsResponseWire, data);
|
|
160
|
+
}
|
|
161
|
+
return fromWire(data, schemas.listEntitlementsResponse);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Get entitlement
|
|
167
|
+
*
|
|
168
|
+
* Get an entitlement by ID. To check entitlement access, use the entitlement
|
|
169
|
+
* access endpoints instead.
|
|
170
|
+
*
|
|
171
|
+
* GET /openmeter/entitlements/{entitlementId}
|
|
172
|
+
*/
|
|
173
|
+
export function getEntitlement(client, req, options) {
|
|
174
|
+
return request(() => {
|
|
175
|
+
const pathParamsInput = {
|
|
176
|
+
entitlementId: req.entitlementId,
|
|
177
|
+
};
|
|
178
|
+
const pathParams = client._options.validate
|
|
179
|
+
? toPathWire(pathParamsInput, schemas.getEntitlementPathParams)
|
|
180
|
+
: pathParamsInput;
|
|
181
|
+
if (client._options.validate) {
|
|
182
|
+
assertValid(schemas.getEntitlementPathParamsWire, pathParams);
|
|
183
|
+
}
|
|
184
|
+
const path = `openmeter/entitlements/${(() => {
|
|
185
|
+
if (pathParams.entitlementId === undefined) {
|
|
186
|
+
throw new Error('missing path parameter: entitlementId');
|
|
187
|
+
}
|
|
188
|
+
return encodeURIComponent(String(pathParams.entitlementId));
|
|
189
|
+
})()}`;
|
|
190
|
+
return http(client)
|
|
191
|
+
.get(path, options)
|
|
192
|
+
.json()
|
|
193
|
+
.then((data) => {
|
|
194
|
+
if (client._options.validate) {
|
|
195
|
+
assertValid(schemas.getEntitlementResponseWire, data);
|
|
196
|
+
}
|
|
197
|
+
return fromWire(data, schemas.getEntitlementResponse);
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Get customer entitlement value
|
|
203
|
+
*
|
|
204
|
+
* Get the customer's access through a single entitlement, optionally evaluated at
|
|
205
|
+
* a point in time.
|
|
206
|
+
*
|
|
207
|
+
* GET /openmeter/customers/{customerId}/entitlements/{entitlementId}/value
|
|
208
|
+
*/
|
|
209
|
+
export function getCustomerEntitlementValue(client, req, options) {
|
|
210
|
+
return request(() => {
|
|
211
|
+
const pathParamsInput = {
|
|
212
|
+
customerId: req.customerId,
|
|
213
|
+
entitlementId: req.entitlementId,
|
|
214
|
+
};
|
|
215
|
+
const pathParams = client._options.validate
|
|
216
|
+
? toPathWire(pathParamsInput, schemas.getCustomerEntitlementValuePathParams)
|
|
217
|
+
: pathParamsInput;
|
|
218
|
+
if (client._options.validate) {
|
|
219
|
+
assertValid(schemas.getCustomerEntitlementValuePathParamsWire, pathParams);
|
|
220
|
+
}
|
|
221
|
+
const path = `openmeter/customers/${(() => {
|
|
222
|
+
if (pathParams.customerId === undefined) {
|
|
223
|
+
throw new Error('missing path parameter: customerId');
|
|
224
|
+
}
|
|
225
|
+
return encodeURIComponent(String(pathParams.customerId));
|
|
226
|
+
})()}/entitlements/${(() => {
|
|
227
|
+
if (pathParams.entitlementId === undefined) {
|
|
228
|
+
throw new Error('missing path parameter: entitlementId');
|
|
229
|
+
}
|
|
230
|
+
return encodeURIComponent(String(pathParams.entitlementId));
|
|
231
|
+
})()}/value`;
|
|
232
|
+
const query = toWire({
|
|
233
|
+
expand: req.expand,
|
|
234
|
+
at: req.at,
|
|
235
|
+
}, schemas.getCustomerEntitlementValueQueryParams);
|
|
236
|
+
if (client._options.validate) {
|
|
237
|
+
assertValid(schemas.getCustomerEntitlementValueQueryParamsWire, query);
|
|
238
|
+
}
|
|
239
|
+
const searchParams = toURLSearchParams(query);
|
|
240
|
+
return http(client)
|
|
241
|
+
.get(path, { ...options, searchParams })
|
|
242
|
+
.json()
|
|
243
|
+
.then((data) => {
|
|
244
|
+
if (client._options.validate) {
|
|
245
|
+
assertValid(schemas.getCustomerEntitlementValueResponseWire, data);
|
|
246
|
+
}
|
|
247
|
+
return fromWire(data, schemas.getCustomerEntitlementValueResponse);
|
|
85
248
|
});
|
|
86
249
|
});
|
|
87
250
|
}
|