@openmeter/sdk 1.0.0-beta.1 → 1.0.0-beta.100

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.
Files changed (63) hide show
  1. package/README.md +110 -26
  2. package/dist/cjs/clients/client.cjs +117 -0
  3. package/dist/cjs/clients/client.d.cts +40 -0
  4. package/dist/cjs/clients/client.js.map +1 -0
  5. package/dist/cjs/clients/event.cjs +71 -0
  6. package/dist/cjs/clients/event.d.cts +79 -0
  7. package/dist/cjs/clients/event.js.map +1 -0
  8. package/dist/cjs/clients/meter.cjs +69 -0
  9. package/dist/cjs/clients/meter.d.cts +75 -0
  10. package/dist/cjs/clients/meter.js.map +1 -0
  11. package/dist/cjs/clients/portal.cjs +41 -0
  12. package/dist/cjs/clients/portal.d.cts +22 -0
  13. package/dist/cjs/clients/portal.js.map +1 -0
  14. package/dist/cjs/clients/subject.cjs +60 -0
  15. package/dist/cjs/clients/subject.d.cts +27 -0
  16. package/dist/cjs/clients/subject.js.map +1 -0
  17. package/dist/cjs/index.cjs +24 -0
  18. package/dist/cjs/index.d.cts +15 -0
  19. package/dist/cjs/index.js.map +1 -0
  20. package/dist/cjs/schemas/openapi.cjs +7 -0
  21. package/dist/cjs/schemas/openapi.d.cts +2078 -0
  22. package/dist/cjs/schemas/openapi.js.map +1 -0
  23. package/dist/cjs/test/agent.cjs +266 -0
  24. package/dist/cjs/test/agent.d.cts +2 -0
  25. package/dist/cjs/test/agent.js.map +1 -0
  26. package/dist/cjs/test/mocks.cjs +44 -0
  27. package/dist/cjs/test/mocks.d.cts +14 -0
  28. package/dist/cjs/test/mocks.js.map +1 -0
  29. package/dist/cjs/tsconfig.43c3843a.tsbuildinfo +1 -0
  30. package/dist/cjs/tsconfig.d98fa456.tsbuildinfo +1 -0
  31. package/dist/clients/client.d.ts +3 -3
  32. package/dist/clients/client.js +21 -10
  33. package/dist/clients/client.js.map +1 -0
  34. package/dist/clients/event.d.ts +16 -2
  35. package/dist/clients/event.js +44 -18
  36. package/dist/clients/event.js.map +1 -0
  37. package/dist/clients/meter.d.ts +30 -7
  38. package/dist/clients/meter.js +17 -4
  39. package/dist/clients/meter.js.map +1 -0
  40. package/dist/clients/portal.d.ts +22 -0
  41. package/dist/clients/portal.js +37 -0
  42. package/dist/clients/portal.js.map +1 -0
  43. package/dist/clients/subject.d.ts +27 -0
  44. package/dist/clients/subject.js +56 -0
  45. package/dist/clients/subject.js.map +1 -0
  46. package/dist/index.d.ts +6 -2
  47. package/dist/index.js +7 -0
  48. package/dist/index.js.map +1 -0
  49. package/dist/schemas/openapi.d.ts +1876 -212
  50. package/dist/schemas/openapi.js +1 -0
  51. package/dist/schemas/openapi.js.map +1 -0
  52. package/dist/test/agent.js +190 -32
  53. package/dist/test/agent.js.map +1 -0
  54. package/dist/test/mocks.d.ts +4 -1
  55. package/dist/test/mocks.js +28 -8
  56. package/dist/test/mocks.js.map +1 -0
  57. package/dist/tsconfig.tsbuildinfo +1 -1
  58. package/package.json +65 -51
  59. package/clients/client.ts +0 -153
  60. package/clients/event.ts +0 -109
  61. package/clients/meter.ts +0 -84
  62. package/index.ts +0 -17
  63. package/schemas/openapi.ts +0 -421
@@ -3,42 +3,321 @@
3
3
  * Do not make direct changes to the file.
4
4
  */
5
5
  export interface paths {
6
- "/api/v1/events": {
7
- /** @description Ingest events */
8
- post: operations["ingestEvents"];
9
- };
10
- "/api/v1/meters": {
11
- /** @description List meters */
12
- get: operations["listMeters"];
13
- /** @description Create meter */
14
- post: operations["createMeter"];
15
- };
16
- "/api/v1/meters/{meterIdOrSlug}": {
17
- /** @description Get meter by slugs */
18
- get: operations["getMeter"];
19
- /** @description Delete meter by slug */
20
- delete: operations["deleteMeter"];
21
- };
22
- "/api/v1/meters/{meterIdOrSlug}/values": {
23
- /** @description Get meter values */
24
- get: operations["getMeterValues"];
25
- };
26
- "/api/v1/namespaces": {
27
- /** @description Create namespace */
28
- post: operations["createNamespace"];
6
+ '/api/v1/events': {
7
+ /**
8
+ * List ingested events
9
+ * @description List ingested events within a time range.
10
+ */
11
+ get: operations['listEvents'];
12
+ /**
13
+ * Ingest events
14
+ * @description Ingests an event or batch of events following the CloudEvents specification.
15
+ */
16
+ post: operations['ingestEvents'];
17
+ };
18
+ '/api/v1/meters': {
19
+ /**
20
+ * List meters
21
+ * @description List meters.
22
+ */
23
+ get: operations['listMeters'];
24
+ /**
25
+ * ☁ Create meter
26
+ * @description *Available in OpenMeter Cloud.*
27
+ * *In the open-source version, meters are created in the configuration file.*
28
+ *
29
+ * Create a meter.
30
+ */
31
+ post: operations['createMeter'];
32
+ };
33
+ '/api/v1/meters/{meterIdOrSlug}': {
34
+ /**
35
+ * Get meter
36
+ * @description Get meter by ID or slug
37
+ */
38
+ get: operations['getMeter'];
39
+ /**
40
+ * ☁ Delete meter
41
+ * @description *Available in OpenMeter Cloud.*
42
+ *
43
+ * Delete a meter by ID or slug.
44
+ */
45
+ delete: operations['deleteMeter'];
46
+ };
47
+ '/api/v1/meters/{meterIdOrSlug}/query': {
48
+ /**
49
+ * Query meter
50
+ * @description Query meter for usage.
51
+ */
52
+ get: operations['queryMeter'];
53
+ };
54
+ '/api/v1/meters/{meterIdOrSlug}/subjects': {
55
+ /**
56
+ * List meter subjects
57
+ * @description List subjects for a meter.
58
+ */
59
+ get: operations['listMeterSubjects'];
60
+ };
61
+ '/api/v1/portal/tokens': {
62
+ /**
63
+ * ☁ List portal tokens
64
+ * @description *Available in OpenMeter Cloud.*
65
+ *
66
+ * List consumer portal tokens.
67
+ */
68
+ get: operations['listPortalTokens'];
69
+ /**
70
+ * Create portal token
71
+ * @description Create a consumer portal token.
72
+ */
73
+ post: operations['createPortalToken'];
74
+ };
75
+ '/api/v1/portal/tokens/invalidate': {
76
+ /**
77
+ * ☁ Invalidate portal tokens
78
+ * @description *Available in OpenMeter Cloud.*
79
+ *
80
+ * Invalidates consumer portal tokens by ID or subject.
81
+ */
82
+ post: operations['invalidatePortalTokens'];
83
+ };
84
+ '/api/v1/subjects': {
85
+ /**
86
+ * ☁ List subjects
87
+ * @description *Available in OpenMeter Cloud.*
88
+ *
89
+ * List subjects.
90
+ */
91
+ get: operations['listSubjects'];
92
+ /**
93
+ * ☁ Upsert subject
94
+ * @description *Available in OpenMeter Cloud.*
95
+ *
96
+ * Upserts a subject. Creates or updates subject.
97
+ * If the subject doesn't exist, it will be created.
98
+ * If the subject exists, it will be partially updated with the provided fields.
99
+ */
100
+ post: operations['upsertSubject'];
101
+ };
102
+ '/api/v1/subjects/{subjectIdOrKey}': {
103
+ /**
104
+ * ☁ Get subject
105
+ * @description *Available in OpenMeter Cloud.*
106
+ *
107
+ * Get subject by ID or key.
108
+ */
109
+ get: operations['getSubject'];
110
+ /**
111
+ * ☁ Delete subject
112
+ * @description *Available in OpenMeter Cloud.*
113
+ *
114
+ * Delete a subject by ID or key.
115
+ */
116
+ delete: operations['deleteSubject'];
117
+ };
118
+ '/api/v1/portal/meters/{meterSlug}/query': {
119
+ /**
120
+ * Query portal meter
121
+ * @description Query meter for consumer portal. This endpoint is publicly exposable to consumers.
122
+ */
123
+ get: operations['queryPortalMeter'];
124
+ };
125
+ '/api/v1/entitlements': {
126
+ /**
127
+ * List entitlements
128
+ * @description List entitlements.
129
+ */
130
+ get: operations['listEntitlements'];
131
+ };
132
+ '/api/v1/features': {
133
+ /**
134
+ * List features
135
+ * @description List features.
136
+ */
137
+ get: operations['listFeatures'];
138
+ /**
139
+ * Create feature
140
+ * @description Creates a feature.
141
+ */
142
+ post: operations['createFeature'];
143
+ };
144
+ '/api/v1/features/{featureId}': {
145
+ /**
146
+ * Get feature
147
+ * @description Get feature by id.
148
+ */
149
+ get: operations['getFeature'];
150
+ /**
151
+ * Delete feature
152
+ * @description Delete a feature by key.
153
+ */
154
+ delete: operations['deleteFeature'];
155
+ };
156
+ '/api/v1/grants': {
157
+ /**
158
+ * List grants
159
+ * @description List all grants.
160
+ */
161
+ get: operations['listGrants'];
162
+ };
163
+ '/api/v1/grants/{grantId}': {
164
+ /**
165
+ * Delete a grant
166
+ * @description Void (delete) a grant. A grant can only be deleted if it hasn't been used.
167
+ */
168
+ delete: operations['voidGrant'];
169
+ };
170
+ '/api/v1/subjects/{subjectIdOrKey}/entitlements': {
171
+ /**
172
+ * List entitlements
173
+ * @description List all entitlements for a subject.
174
+ */
175
+ get: operations['listSubjectEntitlements'];
176
+ /**
177
+ * Create entitlement
178
+ * @description Create an entitlement for a subject.
179
+ */
180
+ post: operations['createEntitlement'];
181
+ };
182
+ '/api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementId}': {
183
+ /**
184
+ * Get entitlement
185
+ * @description Get entitlement by id.
186
+ */
187
+ get: operations['getEntitlement'];
188
+ /**
189
+ * Delete entitlement
190
+ * @description Delete an entitlement by id.
191
+ */
192
+ delete: operations['deleteEntitlement'];
193
+ };
194
+ '/api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementId}/grants': {
195
+ /**
196
+ * List grants for an entitlement
197
+ * @description List all grants for an entitlement.
198
+ */
199
+ get: operations['listEntitlementGrants'];
200
+ /**
201
+ * Create grant
202
+ * @description Create a grant for an entitlement.
203
+ */
204
+ post: operations['createGrant'];
205
+ };
206
+ '/api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementIdOrFeatureKey}/value': {
207
+ /**
208
+ * Get the balance of a specific entitlement.
209
+ * @description Get the balance of a specific entitlement.
210
+ */
211
+ get: operations['getEntitlementValue'];
212
+ };
213
+ '/api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementId}/history': {
214
+ /**
215
+ * Get the balance history of a specific entitlement.
216
+ * @description Get the balance history of a specific entitlement.
217
+ *
218
+ * The windows are inclusive at their start and exclusive at their end.
219
+ * The last window may be smaller than the window size and is inclusive at both ends.
220
+ */
221
+ get: operations['getEntitlementHistory'];
222
+ };
223
+ '/api/v1/subjects/{subjectIdOrKey}/entitlements/{entitlementId}/reset': {
224
+ /**
225
+ * Reset entitlement
226
+ * @description Reset the entitlement usage and start a new period. Grants that can be are rolled over.
227
+ */
228
+ post: operations['resetEntitlementUsage'];
29
229
  };
30
230
  }
31
231
  export type webhooks = Record<string, never>;
32
232
  export interface components {
33
233
  schemas: {
34
234
  /**
35
- * @description A Problem Details object (RFC 7807)
235
+ * @description Metadata fields for a resource.
236
+ * These fields are automatically populated by the system for the entities we manage.
237
+ */
238
+ SharedMetaFields: {
239
+ /**
240
+ * @description Readonly unique ULID identifier.
241
+ *
242
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
243
+ */
244
+ id: string;
245
+ /**
246
+ * Format: date-time
247
+ * @description The date and time the resource was created.
248
+ * @example 2023-01-01T00:00:00Z
249
+ */
250
+ createdAt: string;
251
+ /**
252
+ * Format: date-time
253
+ * @description The date and time the resource was last updated.
254
+ * @example 2023-01-01T00:00:00Z
255
+ */
256
+ updatedAt: string;
257
+ /**
258
+ * Format: date-time
259
+ * @description The date and time the resource was deleted.
260
+ * @example 2023-01-01T00:00:00Z
261
+ */
262
+ deletedAt: string;
263
+ };
264
+ /**
265
+ * @description Conflict
266
+ * @example {
267
+ * "type": "about:blank",
268
+ * "title": "Conflict",
269
+ * "status": 409,
270
+ * "detail": "ledger (default.01HXVNDJR532E8GTBVSC2XK5D4) already exitst for subject subject-1",
271
+ * "instance": "urn:request:local/JMOlctsKV8-000001",
272
+ * "conflictingEntityId": "01HXVNDJR532E8GTBVSC2XK5D4"
273
+ * }
274
+ */
275
+ ConflictProblem: {
276
+ /**
277
+ * Format: uri
278
+ * @description Type contains a URI that identifies the problem type.
279
+ * @example urn:problem-type:bad-request
280
+ */
281
+ type: string;
282
+ /**
283
+ * @description A a short, human-readable summary of the problem type.
284
+ * @example Bad Request
285
+ */
286
+ title: string;
287
+ /**
288
+ * Format: int32
289
+ * @description The HTTP status code generated by the origin server for this occurrence of the problem.
290
+ * @example 400
291
+ */
292
+ status: number;
293
+ /**
294
+ * @description A human-readable explanation specific to this occurrence of the problem.
295
+ * @example body must be a JSON object
296
+ */
297
+ detail: string;
298
+ /**
299
+ * Format: uri
300
+ * @description A URI reference that identifies the specific occurrence of the problem.
301
+ * @example urn:request:local/JMOlctsKV8-000001
302
+ */
303
+ instance?: string;
304
+ extensions?: {
305
+ /**
306
+ * @description The id of the conflicting entity.
307
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
308
+ */
309
+ conflictingEntityId: string;
310
+ };
311
+ [key: string]: unknown;
312
+ };
313
+ /**
314
+ * @description A Problem Details object (RFC 7807).
315
+ * Additional properties specific to the problem type may be present.
36
316
  * @example {
37
317
  * "type": "urn:problem-type:bad-request",
38
318
  * "title": "Bad Request",
39
319
  * "status": 400,
40
- * "detail": "header Content-Type has unexpected value \"application/xml\"",
41
- * "instance": "urn:request:local/JMOlctsKV8-000001"
320
+ * "detail": "body must be a JSON object"
42
321
  * }
43
322
  */
44
323
  Problem: {
@@ -61,7 +340,7 @@ export interface components {
61
340
  status: number;
62
341
  /**
63
342
  * @description A human-readable explanation specific to this occurrence of the problem.
64
- * @example header Content-Type has unexpected value \"application/xml\"
343
+ * @example body must be a JSON object
65
344
  */
66
345
  detail: string;
67
346
  /**
@@ -72,7 +351,22 @@ export interface components {
72
351
  instance?: string;
73
352
  [key: string]: unknown;
74
353
  };
75
- /** @description CloudEvents Specification JSON Schema */
354
+ /**
355
+ * @description CloudEvents Specification JSON Schema
356
+ * @example {
357
+ * "id": "5c10fade-1c9e-4d6c-8275-c52c36731d3c",
358
+ * "source": "service-name",
359
+ * "specversion": "1.0",
360
+ * "type": "prompt",
361
+ * "subject": "customer-id",
362
+ * "time": "2023-01-01T01:01:01.001Z",
363
+ * "data": {
364
+ * "tokens": "1234",
365
+ * "model": "gpt-4-turbo",
366
+ * "type": "input"
367
+ * }
368
+ * }
369
+ */
76
370
  Event: {
77
371
  /**
78
372
  * @description Identifies the event.
@@ -82,7 +376,7 @@ export interface components {
82
376
  /**
83
377
  * Format: uri-reference
84
378
  * @description Identifies the context in which an event happened.
85
- * @example services/service-0
379
+ * @example service-name
86
380
  */
87
381
  source: string;
88
382
  /**
@@ -92,7 +386,7 @@ export interface components {
92
386
  specversion: string;
93
387
  /**
94
388
  * @description Describes the type of event related to the originating occurrence.
95
- * @example api_request
389
+ * @example prompt
96
390
  */
97
391
  type: string;
98
392
  /**
@@ -100,7 +394,7 @@ export interface components {
100
394
  * @example application/json
101
395
  * @enum {string|null}
102
396
  */
103
- datacontenttype?: "application/json" | null;
397
+ datacontenttype?: 'application/json' | null;
104
398
  /**
105
399
  * Format: uri
106
400
  * @description Identifies the schema that data adheres to.
@@ -108,7 +402,7 @@ export interface components {
108
402
  dataschema?: string | null;
109
403
  /**
110
404
  * @description Describes the subject of the event in the context of the event producer (identified by source).
111
- * @example customer_id
405
+ * @example customer-id
112
406
  */
113
407
  subject: string;
114
408
  /**
@@ -120,295 +414,1665 @@ export interface components {
120
414
  /**
121
415
  * @description The event payload.
122
416
  * @example {
123
- * "duration_ms": "12",
124
- * "path": "/hello"
417
+ * "tokens": "1234",
418
+ * "model": "gpt-4-turbo"
125
419
  * }
126
420
  */
127
421
  data?: {
128
422
  [key: string]: unknown;
129
423
  };
130
424
  };
131
- Meter: {
132
- /**
133
- * @description A unique identifier for the meter.
134
- * @example 01G65Z755AFWAKHE12NY0CQ9FH
135
- */
136
- id?: string;
137
- /**
138
- * @description A unique identifier for the meter.
139
- * @example my-meter
140
- */
141
- slug: string;
425
+ /**
426
+ * @description An ingested event with optional validation error.
427
+ * @example {
428
+ * "event": {
429
+ * "id": "5c10fade-1c9e-4d6c-8275-c52c36731d3d",
430
+ * "source": "service-name",
431
+ * "specversion": "1.0",
432
+ * "type": "prompt",
433
+ * "subject": "customer-id",
434
+ * "time": "2023-01-01T01:01:01.001Z",
435
+ * "data": {
436
+ * "tokens": "1234",
437
+ * "model": "gpt-4-turbo"
438
+ * }
439
+ * },
440
+ * "validationError": "meter not found for event"
441
+ * }
442
+ */
443
+ IngestedEvent: {
444
+ event: components['schemas']['Event'];
445
+ /** @example invalid event */
446
+ validationError?: string;
447
+ };
448
+ /**
449
+ * @description A feature is a feature or service offered to a customer.
450
+ * For example: CPU-Hours, Tokens, API Calls, etc.
451
+ */
452
+ FeatureCreateInputs: {
142
453
  /**
143
- * @description A description of the meter.
144
- * @example My Meter Description
454
+ * @description The unique key of the feature to reference it from your application.
455
+ *
456
+ * @example gpt4_tokens
145
457
  */
146
- description?: string | null;
147
- aggregation: components["schemas"]["MeterAggregation"];
458
+ key: string;
148
459
  /**
149
- * @description The event type to aggregate.
150
- * @example api_request
460
+ * @description The name of the feature.
461
+ *
462
+ * @example AI Tokens
151
463
  */
152
- eventType: string;
464
+ name: string;
465
+ /** @description Additional metadata for the feature. */
466
+ metadata?: {
467
+ [key: string]: string;
468
+ };
153
469
  /**
154
- * @description JSONPath expression to extract the value from the event data.
155
- * @example $.duration_ms
470
+ * @description The meter that the feature is associated with and decreases grants by usage.
471
+ * If present, the usage of the feature can be metered.
472
+ *
473
+ * @example tokens_total
156
474
  */
157
- valueProperty: string;
475
+ meterSlug?: string;
158
476
  /**
159
- * @description Named JSONPath expressions to extract the group by values from the event data.
477
+ * @description Optional meter group by filters. Useful if the meter scope is broader than what feature tracks.
478
+ *
160
479
  * @example {
161
- * "duration_ms": "$.duration_ms",
162
- * "path": "$.path"
480
+ * "model": "gpt-4"
163
481
  * }
164
482
  */
165
- groupBy?: {
483
+ meterGroupByFilters?: {
166
484
  [key: string]: string;
167
485
  };
168
- windowSize: components["schemas"]["WindowSize"];
169
486
  };
170
487
  /**
171
- * @description The aggregation type to use for the meter.
172
- * @enum {string}
488
+ * @description A feature is a feature or service offered to a customer.
489
+ * For example: CPU-Hours, Tokens, API Calls, etc.
173
490
  */
174
- MeterAggregation: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX";
175
- /** @enum {string} */
176
- WindowSize: "MINUTE" | "HOUR" | "DAY";
177
- MeterValue: {
178
- /** @description The subject of the meter value. */
179
- subject?: string;
180
- /** Format: date-time */
181
- windowStart: string;
182
- /** Format: date-time */
183
- windowEnd: string;
184
- value: number;
185
- groupBy?: {
491
+ Feature: {
492
+ /**
493
+ * Format: date-time
494
+ * @description If the feature is archived, it will not be used for grants or usage.
495
+ *
496
+ * @example 2023-01-01T00:00:00Z
497
+ */
498
+ archivedAt?: string;
499
+ } & components['schemas']['FeatureCreateInputs'] & components['schemas']['SharedMetaFields'];
500
+ EntitlementCreateSharedFields: {
501
+ /**
502
+ * @description The feature the subject is entitled to use.
503
+ * Either featureKey or featureId is required.
504
+ *
505
+ * @example example-feature-key
506
+ */
507
+ featureKey?: string;
508
+ /**
509
+ * @description The feature the subject is entitled to use.
510
+ * Either featureKey or featureId is required.
511
+ *
512
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
513
+ */
514
+ featureId?: string;
515
+ /** @description Additional metadata for the feature. */
516
+ metadata?: {
186
517
  [key: string]: string;
187
- } | null;
518
+ };
519
+ usagePeriod?: components['schemas']['RecurringPeriodCreateInput'];
188
520
  };
189
- IdOrSlug: string;
190
- Namespace: {
521
+ EntitlementSharedFields: components['schemas']['SharedMetaFields'] & components['schemas']['EntitlementCreateSharedFields'] & {
191
522
  /**
192
- * @description A namespace
193
- * @example my-namesapce
523
+ * @description The feature the subject is entitled to use.
524
+ * Either featureKey or featureId is required.
525
+ *
526
+ * @example example-feature-key
194
527
  */
195
- namespace: string;
196
- };
197
- };
198
- responses: {
199
- /** @description Bad Request */
200
- BadRequestProblemResponse: {
201
- content: {
202
- "application/problem+json": components["schemas"]["Problem"];
203
- };
528
+ featureKey: string;
529
+ /**
530
+ * @description The feature the subject is entitled to use.
531
+ * Either featureKey or featureId is required.
532
+ *
533
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
534
+ */
535
+ featureId: string;
536
+ /**
537
+ * @description The identifier key unique to the subject
538
+ * @example customer-1
539
+ */
540
+ subjectKey: string;
541
+ usagePeriod?: components['schemas']['RecurringPeriod'];
542
+ currentUsagePeriod?: components['schemas']['Period'];
204
543
  };
205
- /** @description Method not allowed, feature not supported */
206
- MethodNotAllowedProblemResponse: {
207
- content: {
208
- "application/problem+json": components["schemas"]["Problem"];
209
- };
544
+ EntitlementMeteredCreateInputs: components['schemas']['EntitlementCreateSharedFields'] & {
545
+ /**
546
+ * @example metered
547
+ * @enum {string}
548
+ */
549
+ type: 'metered';
550
+ /**
551
+ * @description If softLimit=true the subject can use the feature even if the entitlement is exhausted.
552
+ *
553
+ * @default false
554
+ */
555
+ isSoftLimit?: boolean;
556
+ /**
557
+ * @description If unlimited=true the subject can use the feature an unlimited amount.
558
+ *
559
+ * @default false
560
+ */
561
+ isUnlimited?: boolean;
562
+ usagePeriod: components['schemas']['RecurringPeriodCreateInput'];
563
+ /**
564
+ * Format: double
565
+ * @description You can issue usage automatically after reset. This usage is not rolled over.
566
+ */
567
+ issueAfterReset?: number;
210
568
  };
211
- /** @description Not Found */
212
- NotFoundProblemResponse: {
213
- content: {
214
- "application/problem+json": components["schemas"]["Problem"];
215
- };
569
+ EntitlementCreateInputs: components['schemas']['EntitlementMeteredCreateInputs'] | components['schemas']['EntitlementStaticCreateInputs'] | components['schemas']['EntitlementBooleanCreateInputs'];
570
+ /** @description Entitles a subject to use a feature. */
571
+ EntitlementMetered: components['schemas']['EntitlementMeteredCreateInputs'] & components['schemas']['EntitlementMeteredCalculatedFields'] & components['schemas']['EntitlementSharedFields'];
572
+ /** @description Calculated fields for a metered entitlement. */
573
+ EntitlementMeteredCalculatedFields: {
574
+ /**
575
+ * Format: date-time
576
+ * @description The last time the meter was reset.
577
+ *
578
+ * @example 2023-01-01T00:00:00Z
579
+ */
580
+ lastReset: string;
581
+ currentUsagePeriod: components['schemas']['Period'];
216
582
  };
217
- /** @description Not Implemented */
218
- NotImplementedProblemResponse: {
219
- content: {
220
- "application/problem+json": components["schemas"]["Problem"];
221
- };
583
+ EntitlementStaticCreateInputs: components['schemas']['EntitlementCreateSharedFields'] & {
584
+ /**
585
+ * @example static
586
+ * @enum {string}
587
+ */
588
+ type: 'static';
589
+ /**
590
+ * @description The JSON parsable config of the entitlement.
591
+ *
592
+ * @example {"key1": "value1"}
593
+ */
594
+ config: string;
222
595
  };
223
- /** @description Unexpected error */
224
- UnexpectedProblemResponse: {
225
- content: {
226
- "application/problem+json": components["schemas"]["Problem"];
227
- };
596
+ /** @description Entitles a subject to use a feature. */
597
+ EntitlementStatic: components['schemas']['EntitlementStaticCreateInputs'] & components['schemas']['EntitlementSharedFields'];
598
+ EntitlementBooleanCreateInputs: components['schemas']['EntitlementCreateSharedFields'] & {
599
+ /**
600
+ * @example boolean
601
+ * @enum {string}
602
+ */
603
+ type: 'boolean';
228
604
  };
229
- };
230
- parameters: {
231
- /** @description A unique identifier for the meter. */
232
- meterIdOrSlug: components["schemas"]["IdOrSlug"];
605
+ /** @description Entitles a subject to use a feature. */
606
+ EntitlementBoolean: components['schemas']['EntitlementBooleanCreateInputs'] & components['schemas']['EntitlementSharedFields'];
607
+ Entitlement: components['schemas']['EntitlementMetered'] | components['schemas']['EntitlementStatic'] | components['schemas']['EntitlementBoolean'];
233
608
  /**
234
- * @description Optional namespace
235
- * @default default
609
+ * @description A segment of the grant burn down history.
610
+ *
611
+ * A given segment represents the usage of a grant in a specific period.
236
612
  */
237
- namespaceParam?: string;
238
- };
239
- requestBodies: never;
240
- headers: never;
241
- pathItems: never;
242
- }
243
- export type external = Record<string, never>;
244
- export interface operations {
245
- /** @description Ingest events */
246
- ingestEvents: {
247
- parameters: {
248
- header?: {
249
- "OM-Namespace"?: components["parameters"]["namespaceParam"];
613
+ GrantBurnDownHistorySegment: {
614
+ period?: components['schemas']['Period'];
615
+ /**
616
+ * Format: double
617
+ * @description The usage of the grant in the period.
618
+ *
619
+ * @example 100
620
+ */
621
+ usage?: number;
622
+ /**
623
+ * Format: double
624
+ * @description Overuse that wasn't covered by grants.
625
+ *
626
+ * @example 25
627
+ */
628
+ overage?: number;
629
+ /**
630
+ * Format: double
631
+ * @description The entitlement balance at the start of the period.
632
+ *
633
+ * @example 100
634
+ */
635
+ balanceAtStart?: number;
636
+ /**
637
+ * @description The balance breakdown of each active grant at the start of the period: GrantID: Balance
638
+ *
639
+ * @example {
640
+ * "01ARZ3NDEKTSV4RRFFQ69G5FAV": 100
641
+ * }
642
+ */
643
+ grantBalancesAtStart?: {
644
+ [key: string]: number;
250
645
  };
251
- };
252
- requestBody: {
253
- content: {
254
- "application/cloudevents+json": components["schemas"]["Event"];
646
+ /**
647
+ * Format: double
648
+ * @description The entitlement balance at the end of the period.
649
+ *
650
+ * @example 100
651
+ */
652
+ balanceAtEnd?: number;
653
+ /**
654
+ * @description The balance breakdown of each active grant at the start of the period: GrantID: Balance
655
+ *
656
+ * @example {
657
+ * "01ARZ3NDEKTSV4RRFFQ69G5FAV": 100
658
+ * }
659
+ */
660
+ grantBalancesAtEnd?: {
661
+ [key: string]: number;
255
662
  };
663
+ /** @description Which grants were actually burnt down in the period and by what amount. */
664
+ grantUsages?: readonly components['schemas']['GrantUsageRecord'][];
256
665
  };
257
- responses: {
258
- /** @description OK */
259
- 200: {
260
- content: never;
261
- };
262
- 400: components["responses"]["BadRequestProblemResponse"];
263
- default: components["responses"]["UnexpectedProblemResponse"];
666
+ GrantUsageRecord: {
667
+ /**
668
+ * @description The id of the grant.
669
+ *
670
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
671
+ */
672
+ grantId?: string;
673
+ /**
674
+ * Format: double
675
+ * @description The usage of the grant.
676
+ *
677
+ * @example 100
678
+ */
679
+ usage?: number;
680
+ };
681
+ /** @description A window of balance history. */
682
+ BalanceHistoryWindow: {
683
+ period?: components['schemas']['Period'];
684
+ /**
685
+ * Format: double
686
+ * @description The total usage of the feature in the period.
687
+ *
688
+ * @example 100
689
+ */
690
+ usage?: number;
691
+ /**
692
+ * Format: double
693
+ * @description The entitlement balance at the start of the period.
694
+ *
695
+ * @example 100
696
+ */
697
+ balanceAtStart?: number;
698
+ };
699
+ /** @description The windowed balance history. */
700
+ WindowedBalanceHistory: {
701
+ /**
702
+ * @description The windowed balance history.
703
+ * Only returns rows for windows where there was usage.
704
+ */
705
+ windowedHistory?: components['schemas']['BalanceHistoryWindow'][];
706
+ /** @description The grant burn down history in the period. */
707
+ burndownHistory?: components['schemas']['GrantBurnDownHistorySegment'][];
708
+ };
709
+ /** @description A time period */
710
+ Period: {
711
+ /**
712
+ * Format: date-time
713
+ * @description Period start time where the amount was applied. If applicable.
714
+ *
715
+ * @example 2023-01-01T00:00:00Z
716
+ */
717
+ from: string;
718
+ /**
719
+ * Format: date-time
720
+ * @description Period end time where the amount was applied. If applicable.
721
+ *
722
+ * @example 2023-01-01T00:00:00Z
723
+ */
724
+ to: string;
725
+ };
726
+ /**
727
+ * @description List of pre-defined periods that can be used for recurring & scheduling.
728
+ *
729
+ * DAY: Every day
730
+ * WEEK: Every week
731
+ * MONTH: Every month
732
+ * YEAR: Every year
733
+ *
734
+ * @enum {string}
735
+ */
736
+ RecurringPeriodEnum: 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';
737
+ /** @description Recurring period of an entitlement. */
738
+ RecurringPeriodCreateInput: {
739
+ interval: components['schemas']['RecurringPeriodEnum'];
740
+ /**
741
+ * Format: date-time
742
+ * @description An arbitrary anchor to base the recurring period on.
743
+ * If not provided then defaults to now truncated to the hour.
744
+ */
745
+ anchor?: string;
746
+ };
747
+ /** @description Recurring period of an entitlement. */
748
+ RecurringPeriod: {
749
+ interval: components['schemas']['RecurringPeriodEnum'];
750
+ /**
751
+ * Format: date-time
752
+ * @description An arbitrary anchor to base the recurring period on.
753
+ */
754
+ anchor: string;
755
+ };
756
+ /** @description Grants are used to increase balance of specific subjects. */
757
+ EntitlementGrantCreateInput: {
758
+ /**
759
+ * Format: double
760
+ * @description The amount to grant. Should be a positive number.
761
+ *
762
+ * @example 100
763
+ */
764
+ amount: number;
765
+ /**
766
+ * @description The priority of the grant. Grants with higher priority are applied first.
767
+ * Priority is a positive decimal numbers. With lower numbers indicating higher importance.
768
+ * For example, a priority of 1 is more urgent than a priority of 2.
769
+ * When there are several grants available for the same subject, the system selects the grant with the highest priority.
770
+ * In cases where grants share the same priority level, the grant closest to its expiration will be used first.
771
+ * In the case of two grants have identical priorities and expiration dates, the system will use the grant that was created first.
772
+ *
773
+ * @default 1
774
+ * @example 1
775
+ */
776
+ priority?: number;
777
+ /**
778
+ * Format: date-time
779
+ * @description The effective time. Provided value will be ceiled to metering windowSize (minute).
780
+ *
781
+ * @example 2023-01-01T00:00:00Z
782
+ */
783
+ effectiveAt: string;
784
+ expiration: components['schemas']['ExpirationPeriod'];
785
+ /**
786
+ * Format: double
787
+ * @description Grants are rolled over at reset, after which they can have a different balance compared to what they had before the reset.
788
+ *
789
+ * Balance after the reset is calculated as:
790
+ * Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset, MinRolloverAmount))
791
+ *
792
+ * @default 0
793
+ * @example 100
794
+ */
795
+ maxRolloverAmount?: number;
796
+ /**
797
+ * Format: double
798
+ * @description Grants are rolled over at reset, after which they can have a different balance compared to what they had before the reset.
799
+ *
800
+ * Balance after the reset is calculated as:
801
+ * Balance_After_Reset = MIN(MaxRolloverAmount, MAX(Balance_Before_Reset, MinRolloverAmount))
802
+ *
803
+ * @default 0
804
+ * @example 100
805
+ */
806
+ minRolloverAmount?: number;
807
+ /**
808
+ * @example {
809
+ * "stripePaymentId": "pi_4OrAkhLvyihio9p51h9iiFnB"
810
+ * }
811
+ */
812
+ metadata?: {
813
+ [key: string]: string;
814
+ };
815
+ recurrence?: components['schemas']['RecurringPeriodCreateInput'];
816
+ };
817
+ EntitlementGrant: components['schemas']['EntitlementGrantCreateInput'] & components['schemas']['SharedMetaFields'] & {
818
+ /**
819
+ * @description The unique entitlement ULID that the grant is associated with.
820
+ *
821
+ * @example 01ARZ3NDEKTSV4RRFFQ69G5FAV
822
+ */
823
+ entitlementId: string;
824
+ /**
825
+ * Format: date-time
826
+ * @description The next time the grant will recurr.
827
+ *
828
+ * @example 2023-01-01T00:00:00Z
829
+ */
830
+ nextRecurrence?: string;
831
+ /**
832
+ * Format: date-time
833
+ * @description The expiration date of the grant.
834
+ *
835
+ * @example 2023-01-01T00:00:00Z
836
+ */
837
+ expiresAt?: string;
838
+ /**
839
+ * Format: date-time
840
+ * @description The date and time the grant was voided (cannot be used after that).
841
+ */
842
+ voidedAt?: string;
843
+ recurrence?: components['schemas']['RecurringPeriod'];
844
+ };
845
+ EntitlementValue: {
846
+ /**
847
+ * @description Whether the subject has access to the feature.
848
+ * @example true
849
+ */
850
+ hasAccess: boolean;
851
+ /**
852
+ * Format: double
853
+ * @description The balance of a metered entitlement.
854
+ * @example 100
855
+ */
856
+ balance?: number;
857
+ /**
858
+ * Format: double
859
+ * @description Total usage of the feature in the period. Includes overages.
860
+ * @example 50
861
+ */
862
+ usage?: number;
863
+ /**
864
+ * Format: double
865
+ * @description The overage of a metered entitlement.
866
+ * @example 0
867
+ */
868
+ overage?: number;
869
+ /**
870
+ * @description The JSON parseable configuration value of a static entitlement.
871
+ * @example {"key1": "value1"}
872
+ */
873
+ config?: string;
874
+ };
875
+ /** @description Expiration period of a grant. */
876
+ ExpirationPeriod: {
877
+ /**
878
+ * @description The expiration period duration like month.
879
+ *
880
+ * @enum {string}
881
+ */
882
+ duration: 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'YEAR';
883
+ /**
884
+ * @description The expiration period count like 12 months.
885
+ *
886
+ * @example 12
887
+ */
888
+ count: number;
889
+ };
890
+ /**
891
+ * @description A meter is a configuration that defines how to match and aggregate events.
892
+ * @example {
893
+ * "slug": "tokens_total",
894
+ * "description": "AI token usage",
895
+ * "aggregation": "SUM",
896
+ * "windowSize": "MINUTE",
897
+ * "eventType": "prompt",
898
+ * "valueProperty": "$.tokens",
899
+ * "groupBy": {
900
+ * "model": "$.model",
901
+ * "type": "$.type"
902
+ * }
903
+ * }
904
+ */
905
+ Meter: {
906
+ /**
907
+ * @description A unique identifier for the meter.
908
+ * @example 01G65Z755AFWAKHE12NY0CQ9FH
909
+ */
910
+ id?: string;
911
+ /**
912
+ * @description A unique, human-readable identifier for the meter. Must consist only alphanumeric and underscore characters.
913
+ * @example tokens_total
914
+ */
915
+ slug: string;
916
+ /**
917
+ * @description A description of the meter.
918
+ * @example AI Token Usage
919
+ */
920
+ description?: string | null;
921
+ aggregation: components['schemas']['MeterAggregation'];
922
+ windowSize: components['schemas']['WindowSize'];
923
+ /**
924
+ * @description The event type to aggregate.
925
+ * @example prompt
926
+ */
927
+ eventType: string;
928
+ /**
929
+ * @description JSONPath expression to extract the value from the ingested event's data property.
930
+ * The ingested value for SUM, AVG, MIN, and MAX aggregations is a number or a string that can be parsed to a number.
931
+ * For UNIQUE_COUNT aggregation, the ingested value must be a string. For COUNT aggregation the valueProperty is ignored.
932
+ *
933
+ * @example $.tokens
934
+ */
935
+ valueProperty?: string;
936
+ /**
937
+ * @description Named JSONPath expressions to extract the group by values from the event data. Keys must be unique and consist only alphanumeric and underscore characters.
938
+ * @example {
939
+ * "model": "$.model",
940
+ * "type": "$.type"
941
+ * }
942
+ */
943
+ groupBy?: {
944
+ [key: string]: string;
945
+ };
946
+ };
947
+ /**
948
+ * @description The aggregation type to use for the meter.
949
+ * @example SUM
950
+ * @enum {string}
951
+ */
952
+ MeterAggregation: 'SUM' | 'COUNT' | 'UNIQUE_COUNT' | 'AVG' | 'MIN' | 'MAX';
953
+ /**
954
+ * @description Aggregation window size.
955
+ * @example MINUTE
956
+ * @enum {string}
957
+ */
958
+ WindowSize: 'MINUTE' | 'HOUR' | 'DAY';
959
+ /**
960
+ * @description The result of a meter query.
961
+ * @example {
962
+ * "from": "2023-01-01T00:00:00Z",
963
+ * "to": "2023-01-02T00:00:00Z",
964
+ * "windowSize": "MINUTE",
965
+ * "data": [
966
+ * {
967
+ * "value": 12,
968
+ * "windowStart": "2023-01-01T00:00:00Z",
969
+ * "windowEnd": "2023-01-02T00:00:00Z",
970
+ * "subject": "customer-id",
971
+ * "groupBy": {
972
+ * "model": "gpt-4-turbo",
973
+ * "type": "prompt"
974
+ * }
975
+ * }
976
+ * ]
977
+ * }
978
+ */
979
+ MeterQueryResult: {
980
+ /**
981
+ * Format: date-time
982
+ * @example 2023-01-01T00:00:00Z
983
+ */
984
+ from?: string;
985
+ /**
986
+ * Format: date-time
987
+ * @example 2023-01-02T00:00:00Z
988
+ */
989
+ to?: string;
990
+ windowSize?: components['schemas']['WindowSize'];
991
+ /**
992
+ * @example [
993
+ * {
994
+ * "value": 12,
995
+ * "windowStart": "2023-01-01T00:00:00Z",
996
+ * "windowEnd": "2023-01-02T00:00:00Z",
997
+ * "subject": "customer-id",
998
+ * "groupBy": {
999
+ * "model": "gpt-4-turbo",
1000
+ * "type": "prompt"
1001
+ * }
1002
+ * }
1003
+ * ]
1004
+ */
1005
+ data: components['schemas']['MeterQueryRow'][];
1006
+ };
1007
+ /**
1008
+ * @description A row in the result of a meter query.
1009
+ * @example {
1010
+ * "value": 12,
1011
+ * "windowStart": "2023-01-01T00:00:00Z",
1012
+ * "windowEnd": "2023-01-02T00:00:00Z",
1013
+ * "subject": "customer-id",
1014
+ * "groupBy": {
1015
+ * "model": "gpt-4-turbo",
1016
+ * "type": "prompt"
1017
+ * }
1018
+ * }
1019
+ */
1020
+ MeterQueryRow: {
1021
+ /** @example 12 */
1022
+ value: number;
1023
+ /**
1024
+ * Format: date-time
1025
+ * @example 2023-01-01T00:00:00Z
1026
+ */
1027
+ windowStart: string;
1028
+ /**
1029
+ * Format: date-time
1030
+ * @example 2023-01-02T00:00:00Z
1031
+ */
1032
+ windowEnd: string;
1033
+ /**
1034
+ * @description The subject of the meter value.
1035
+ * @example customer-id
1036
+ */
1037
+ subject?: string | null;
1038
+ /**
1039
+ * @example {
1040
+ * "model": "gpt-4-turbo",
1041
+ * "type": "prompt"
1042
+ * }
1043
+ */
1044
+ groupBy?: {
1045
+ [key: string]: string;
1046
+ } | null;
1047
+ };
1048
+ /**
1049
+ * @description A consumer portal token.
1050
+ * @example {
1051
+ * "id": "01G65Z755AFWAKHE12NY0CQ9FH",
1052
+ * "subject": "customer-id",
1053
+ * "expiresAt": "2023-01-02T00:00:00Z",
1054
+ * "expired": false,
1055
+ * "createdAt": "2023-01-01T00:00:00Z",
1056
+ * "token": "om_portal_IAnD3PpWW2A2Wr8m9jfzeHlGX8xmCXwG.y5q4S-AWqFu6qjfaFz0zQq4Ez28RsnyVwJffX5qxMvo",
1057
+ * "allowedMeterSlugs": [
1058
+ * "tokens_total"
1059
+ * ]
1060
+ * }
1061
+ */
1062
+ PortalToken: {
1063
+ /** @example 01G65Z755AFWAKHE12NY0CQ9FH */
1064
+ id?: string;
1065
+ /** @example customer-id */
1066
+ subject: string;
1067
+ /**
1068
+ * Format: date-time
1069
+ * @example 2023-01-02T00:00:00Z
1070
+ */
1071
+ expiresAt?: string;
1072
+ expired?: boolean;
1073
+ /**
1074
+ * Format: date-time
1075
+ * @example 2023-01-01T00:00:00Z
1076
+ */
1077
+ createdAt?: string;
1078
+ /**
1079
+ * @description The token is only returned at creation.
1080
+ * @example om_portal_IAnD3PpWW2A2Wr8m9jfzeHlGX8xmCXwG.y5q4S-AWqFu6qjfaFz0zQq4Ez28RsnyVwJffX5qxMvo
1081
+ */
1082
+ token?: string;
1083
+ /**
1084
+ * @description Optional, if defined only the specified meters will be allowed
1085
+ * @example [
1086
+ * "tokens_total"
1087
+ * ]
1088
+ */
1089
+ allowedMeterSlugs?: string[];
1090
+ };
1091
+ /**
1092
+ * @description A subject is a unique identifier for a user or entity.
1093
+ * @example {
1094
+ * "id": "01G65Z755AFWAKHE12NY0CQ9FH",
1095
+ * "key": "customer-id",
1096
+ * "displayName": "Customer Name",
1097
+ * "metadata": {
1098
+ * "hubspotId": "123456"
1099
+ * },
1100
+ * "currentPeriodStart": "2023-01-01T00:00:00Z",
1101
+ * "currentPeriodEnd": "2023-02-01T00:00:00Z",
1102
+ * "stripeCustomerId": "cus_JMOlctsKV8"
1103
+ * }
1104
+ */
1105
+ Subject: {
1106
+ /** @example 01G65Z755AFWAKHE12NY0CQ9FH */
1107
+ id?: string;
1108
+ /** @example customer-id */
1109
+ key: string;
1110
+ /** @example Customer Name */
1111
+ displayName?: string | null;
1112
+ /**
1113
+ * @example {
1114
+ * "hubspotId": "123456"
1115
+ * }
1116
+ */
1117
+ metadata?: {
1118
+ [key: string]: unknown;
1119
+ } | null;
1120
+ /**
1121
+ * Format: date-time
1122
+ * @example 2023-01-01T00:00:00Z
1123
+ */
1124
+ currentPeriodStart?: string | null;
1125
+ /**
1126
+ * Format: date-time
1127
+ * @example 2023-02-01T00:00:00Z
1128
+ */
1129
+ currentPeriodEnd?: string | null;
1130
+ /** @example cus_JMOlctsKV8 */
1131
+ stripeCustomerId?: string | null;
1132
+ };
1133
+ /**
1134
+ * @description A unique identifier.
1135
+ * @example tokens_total
1136
+ */
1137
+ IdOrSlug: string;
1138
+ };
1139
+ responses: {
1140
+ /** @description Ledger Exists */
1141
+ ConflictProblemResponse: {
1142
+ content: {
1143
+ 'application/problem+json': components['schemas']['ConflictProblem'];
1144
+ };
1145
+ };
1146
+ /** @description Bad Request */
1147
+ BadRequestProblemResponse: {
1148
+ content: {
1149
+ 'application/problem+json': components['schemas']['Problem'];
1150
+ };
1151
+ };
1152
+ /** @description Unauthorized */
1153
+ UnauthorizedProblemResponse: {
1154
+ content: {
1155
+ 'application/problem+json': components['schemas']['Problem'];
1156
+ };
1157
+ };
1158
+ /** @description Not Found */
1159
+ NotFoundProblemResponse: {
1160
+ content: {
1161
+ 'application/problem+json': components['schemas']['Problem'];
1162
+ };
1163
+ };
1164
+ /** @description Not Implemented */
1165
+ NotImplementedProblemResponse: {
1166
+ content: {
1167
+ 'application/problem+json': components['schemas']['Problem'];
1168
+ };
1169
+ };
1170
+ /** @description Unexpected error */
1171
+ UnexpectedProblemResponse: {
1172
+ content: {
1173
+ 'application/problem+json': components['schemas']['Problem'];
1174
+ };
1175
+ };
1176
+ };
1177
+ parameters: {
1178
+ /** @description A unique identifier for the meter. */
1179
+ meterIdOrSlug: components['schemas']['IdOrSlug'];
1180
+ /** @description A unique identifier for a subject. */
1181
+ subjectIdOrKey: string;
1182
+ /** @description A unique ULID identifier for a feature. */
1183
+ featureId: string;
1184
+ /** @description A unique identifier for a grant. */
1185
+ grantId: string;
1186
+ /** @description A unique ULID for an entitlement. */
1187
+ entitlementId: string;
1188
+ /** @description The id of the entitlement or the key of the feature. */
1189
+ entitlementIdOrFeatureKey: string;
1190
+ /** @description Include deleted entries. */
1191
+ includeDeleted?: boolean;
1192
+ /** @description Number of entries to return */
1193
+ queryLimit?: number;
1194
+ /** @description Number of entries to skip */
1195
+ queryOffset?: number;
1196
+ /**
1197
+ * @description Start date-time in RFC 3339 format.
1198
+ * Inclusive.
1199
+ */
1200
+ queryFrom?: string;
1201
+ /**
1202
+ * @description End date-time in RFC 3339 format.
1203
+ * Inclusive.
1204
+ */
1205
+ queryTo?: string;
1206
+ /** @description If not specified, a single usage aggregate will be returned for the entirety of the specified period for each subject and group. */
1207
+ queryWindowSize?: components['schemas']['WindowSize'];
1208
+ /**
1209
+ * @description The value is the name of the time zone as defined in the IANA Time Zone Database (http://www.iana.org/time-zones).
1210
+ * If not specified, the UTC timezone will be used.
1211
+ */
1212
+ queryWindowTimeZone?: string;
1213
+ /**
1214
+ * @description Filtering by multiple subjects.
1215
+ *
1216
+ * Usage: ?subject=customer-1&subject=customer-2
1217
+ */
1218
+ queryFilterSubject?: string[];
1219
+ queryFilterGroupBy?: {
1220
+ [key: string]: string;
1221
+ };
1222
+ /**
1223
+ * @description If not specified a single aggregate will be returned for each subject and time window.
1224
+ * `subject` is a reserved group by value.
1225
+ */
1226
+ queryGroupBy?: string[];
1227
+ };
1228
+ requestBodies: never;
1229
+ headers: never;
1230
+ pathItems: never;
1231
+ }
1232
+ export type $defs = Record<string, never>;
1233
+ export type external = Record<string, never>;
1234
+ export interface operations {
1235
+ /**
1236
+ * List ingested events
1237
+ * @description List ingested events within a time range.
1238
+ */
1239
+ listEvents: {
1240
+ parameters: {
1241
+ query?: {
1242
+ from?: components['parameters']['queryFrom'];
1243
+ to?: components['parameters']['queryTo'];
1244
+ /** @description Number of events to return */
1245
+ limit?: number;
1246
+ };
1247
+ };
1248
+ responses: {
1249
+ /** @description List of events for debugging. */
1250
+ 200: {
1251
+ content: {
1252
+ 'application/json': components['schemas']['IngestedEvent'][];
1253
+ };
1254
+ };
1255
+ 400: components['responses']['BadRequestProblemResponse'];
1256
+ 401: components['responses']['UnauthorizedProblemResponse'];
1257
+ default: components['responses']['UnexpectedProblemResponse'];
1258
+ };
1259
+ };
1260
+ /**
1261
+ * Ingest events
1262
+ * @description Ingests an event or batch of events following the CloudEvents specification.
1263
+ */
1264
+ ingestEvents: {
1265
+ /**
1266
+ * @description The event or batch of events to ingest.
1267
+ * The request body must be a CloudEvents JSON object or an array of CloudEvents JSON objects.
1268
+ * The CloudEvents JSON object must adhere to the CloudEvents Specification JSON Schema.
1269
+ */
1270
+ requestBody: {
1271
+ content: {
1272
+ 'application/cloudevents+json': components['schemas']['Event'];
1273
+ 'application/cloudevents-batch+json': components['schemas']['Event'][];
1274
+ };
1275
+ };
1276
+ responses: {
1277
+ /** @description Successfully ingested. */
1278
+ 204: {
1279
+ content: never;
1280
+ };
1281
+ 400: components['responses']['BadRequestProblemResponse'];
1282
+ 401: components['responses']['UnauthorizedProblemResponse'];
1283
+ default: components['responses']['UnexpectedProblemResponse'];
1284
+ };
1285
+ };
1286
+ /**
1287
+ * List meters
1288
+ * @description List meters.
1289
+ */
1290
+ listMeters: {
1291
+ responses: {
1292
+ /** @description List of meters. */
1293
+ 200: {
1294
+ content: {
1295
+ 'application/json': components['schemas']['Meter'][];
1296
+ };
1297
+ };
1298
+ 401: components['responses']['UnauthorizedProblemResponse'];
1299
+ default: components['responses']['UnexpectedProblemResponse'];
1300
+ };
1301
+ };
1302
+ /**
1303
+ * ☁ Create meter
1304
+ * @description *Available in OpenMeter Cloud.*
1305
+ * *In the open-source version, meters are created in the configuration file.*
1306
+ *
1307
+ * Create a meter.
1308
+ */
1309
+ createMeter: {
1310
+ /** @description The meter to create. */
1311
+ requestBody: {
1312
+ content: {
1313
+ 'application/json': components['schemas']['Meter'];
1314
+ };
1315
+ };
1316
+ responses: {
1317
+ /** @description Created. */
1318
+ 201: {
1319
+ content: {
1320
+ 'application/json': components['schemas']['Meter'];
1321
+ };
1322
+ };
1323
+ 400: components['responses']['BadRequestProblemResponse'];
1324
+ 401: components['responses']['UnauthorizedProblemResponse'];
1325
+ 501: components['responses']['NotImplementedProblemResponse'];
1326
+ default: components['responses']['UnexpectedProblemResponse'];
1327
+ };
1328
+ };
1329
+ /**
1330
+ * Get meter
1331
+ * @description Get meter by ID or slug
1332
+ */
1333
+ getMeter: {
1334
+ parameters: {
1335
+ path: {
1336
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
1337
+ };
1338
+ };
1339
+ responses: {
1340
+ /** @description Meter found. */
1341
+ 200: {
1342
+ content: {
1343
+ 'application/json': components['schemas']['Meter'];
1344
+ };
1345
+ };
1346
+ 404: components['responses']['NotFoundProblemResponse'];
1347
+ default: components['responses']['UnexpectedProblemResponse'];
1348
+ };
1349
+ };
1350
+ /**
1351
+ * ☁ Delete meter
1352
+ * @description *Available in OpenMeter Cloud.*
1353
+ *
1354
+ * Delete a meter by ID or slug.
1355
+ */
1356
+ deleteMeter: {
1357
+ parameters: {
1358
+ path: {
1359
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
1360
+ };
1361
+ };
1362
+ responses: {
1363
+ /** @description Meter deleted. */
1364
+ 204: {
1365
+ content: never;
1366
+ };
1367
+ 404: components['responses']['NotFoundProblemResponse'];
1368
+ 501: components['responses']['NotImplementedProblemResponse'];
1369
+ default: components['responses']['UnexpectedProblemResponse'];
264
1370
  };
265
1371
  };
266
- /** @description List meters */
267
- listMeters: {
1372
+ /**
1373
+ * Query meter
1374
+ * @description Query meter for usage.
1375
+ */
1376
+ queryMeter: {
268
1377
  parameters: {
269
- header?: {
270
- "OM-Namespace"?: components["parameters"]["namespaceParam"];
1378
+ query?: {
1379
+ from?: components['parameters']['queryFrom'];
1380
+ to?: components['parameters']['queryTo'];
1381
+ windowSize?: components['parameters']['queryWindowSize'];
1382
+ windowTimeZone?: components['parameters']['queryWindowTimeZone'];
1383
+ subject?: components['parameters']['queryFilterSubject'];
1384
+ filterGroupBy?: components['parameters']['queryFilterGroupBy'];
1385
+ groupBy?: components['parameters']['queryGroupBy'];
1386
+ };
1387
+ path: {
1388
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
271
1389
  };
272
1390
  };
273
1391
  responses: {
274
- /** @description Meters response */
1392
+ /** @description Usage data. */
275
1393
  200: {
276
1394
  content: {
277
- "application/json": components["schemas"]["Meter"][];
1395
+ 'application/json': components['schemas']['MeterQueryResult'];
1396
+ 'text/csv': string;
278
1397
  };
279
1398
  };
280
- default: components["responses"]["UnexpectedProblemResponse"];
1399
+ 400: components['responses']['BadRequestProblemResponse'];
1400
+ 401: components['responses']['UnauthorizedProblemResponse'];
1401
+ default: components['responses']['UnexpectedProblemResponse'];
281
1402
  };
282
1403
  };
283
- /** @description Create meter */
284
- createMeter: {
1404
+ /**
1405
+ * List meter subjects
1406
+ * @description List subjects for a meter.
1407
+ */
1408
+ listMeterSubjects: {
1409
+ parameters: {
1410
+ path: {
1411
+ meterIdOrSlug: components['parameters']['meterIdOrSlug'];
1412
+ };
1413
+ };
1414
+ responses: {
1415
+ /** @description List of subjects. */
1416
+ 200: {
1417
+ content: {
1418
+ 'application/json': string[];
1419
+ };
1420
+ };
1421
+ 400: components['responses']['BadRequestProblemResponse'];
1422
+ default: components['responses']['UnexpectedProblemResponse'];
1423
+ };
1424
+ };
1425
+ /**
1426
+ * ☁ List portal tokens
1427
+ * @description *Available in OpenMeter Cloud.*
1428
+ *
1429
+ * List consumer portal tokens.
1430
+ */
1431
+ listPortalTokens: {
1432
+ parameters: {
1433
+ query?: {
1434
+ /** @description Number of portal tokens to return. Default is 25. */
1435
+ limit?: number;
1436
+ };
1437
+ };
1438
+ responses: {
1439
+ /** @description List of portal tokens. */
1440
+ 200: {
1441
+ content: {
1442
+ 'application/json': components['schemas']['PortalToken'][];
1443
+ };
1444
+ };
1445
+ 400: components['responses']['BadRequestProblemResponse'];
1446
+ 401: components['responses']['UnauthorizedProblemResponse'];
1447
+ 501: components['responses']['NotImplementedProblemResponse'];
1448
+ default: components['responses']['UnexpectedProblemResponse'];
1449
+ };
1450
+ };
1451
+ /**
1452
+ * Create portal token
1453
+ * @description Create a consumer portal token.
1454
+ */
1455
+ createPortalToken: {
1456
+ /** @description The portal token to create. */
1457
+ requestBody: {
1458
+ content: {
1459
+ /**
1460
+ * @example {
1461
+ * "subject": "customer-id",
1462
+ * "allowedMeterSlugs": [
1463
+ * "tokens_total"
1464
+ * ]
1465
+ * }
1466
+ */
1467
+ 'application/json': components['schemas']['PortalToken'];
1468
+ };
1469
+ };
1470
+ responses: {
1471
+ /** @description Created. */
1472
+ 200: {
1473
+ content: {
1474
+ 'application/json': components['schemas']['PortalToken'];
1475
+ };
1476
+ };
1477
+ 400: components['responses']['BadRequestProblemResponse'];
1478
+ 401: components['responses']['UnauthorizedProblemResponse'];
1479
+ default: components['responses']['UnexpectedProblemResponse'];
1480
+ };
1481
+ };
1482
+ /**
1483
+ * ☁ Invalidate portal tokens
1484
+ * @description *Available in OpenMeter Cloud.*
1485
+ *
1486
+ * Invalidates consumer portal tokens by ID or subject.
1487
+ */
1488
+ invalidatePortalTokens: {
1489
+ /** @description If no id or subject is specified, all tokens will be invalidated. */
1490
+ requestBody: {
1491
+ content: {
1492
+ 'application/json': {
1493
+ /** @description Invalidate a portal token by ID. */
1494
+ id?: string;
1495
+ /** @description Invalidate all portal tokens for a subject. */
1496
+ subject?: string;
1497
+ };
1498
+ };
1499
+ };
1500
+ responses: {
1501
+ /** @description Portal tokens invalidated. */
1502
+ 204: {
1503
+ content: never;
1504
+ };
1505
+ 400: components['responses']['BadRequestProblemResponse'];
1506
+ 401: components['responses']['UnauthorizedProblemResponse'];
1507
+ 501: components['responses']['NotImplementedProblemResponse'];
1508
+ default: components['responses']['UnexpectedProblemResponse'];
1509
+ };
1510
+ };
1511
+ /**
1512
+ * ☁ List subjects
1513
+ * @description *Available in OpenMeter Cloud.*
1514
+ *
1515
+ * List subjects.
1516
+ */
1517
+ listSubjects: {
1518
+ responses: {
1519
+ /** @description List of subjects. */
1520
+ 200: {
1521
+ content: {
1522
+ 'application/json': components['schemas']['Subject'][];
1523
+ };
1524
+ };
1525
+ 401: components['responses']['UnauthorizedProblemResponse'];
1526
+ default: components['responses']['UnexpectedProblemResponse'];
1527
+ };
1528
+ };
1529
+ /**
1530
+ * ☁ Upsert subject
1531
+ * @description *Available in OpenMeter Cloud.*
1532
+ *
1533
+ * Upserts a subject. Creates or updates subject.
1534
+ * If the subject doesn't exist, it will be created.
1535
+ * If the subject exists, it will be partially updated with the provided fields.
1536
+ */
1537
+ upsertSubject: {
1538
+ /** @description The subject to upsert. */
1539
+ requestBody: {
1540
+ content: {
1541
+ 'application/json': components['schemas']['Subject'][];
1542
+ };
1543
+ };
1544
+ responses: {
1545
+ /** @description Subject upserted. */
1546
+ 200: {
1547
+ content: {
1548
+ 'application/json': components['schemas']['Subject'][];
1549
+ };
1550
+ };
1551
+ 400: components['responses']['BadRequestProblemResponse'];
1552
+ 401: components['responses']['UnauthorizedProblemResponse'];
1553
+ 501: components['responses']['NotImplementedProblemResponse'];
1554
+ default: components['responses']['UnexpectedProblemResponse'];
1555
+ };
1556
+ };
1557
+ /**
1558
+ * ☁ Get subject
1559
+ * @description *Available in OpenMeter Cloud.*
1560
+ *
1561
+ * Get subject by ID or key.
1562
+ */
1563
+ getSubject: {
1564
+ parameters: {
1565
+ path: {
1566
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
1567
+ };
1568
+ };
1569
+ responses: {
1570
+ /** @description Subject found. */
1571
+ 200: {
1572
+ content: {
1573
+ 'application/json': components['schemas']['Subject'];
1574
+ };
1575
+ };
1576
+ 401: components['responses']['UnauthorizedProblemResponse'];
1577
+ 404: components['responses']['NotFoundProblemResponse'];
1578
+ default: components['responses']['UnexpectedProblemResponse'];
1579
+ };
1580
+ };
1581
+ /**
1582
+ * ☁ Delete subject
1583
+ * @description *Available in OpenMeter Cloud.*
1584
+ *
1585
+ * Delete a subject by ID or key.
1586
+ */
1587
+ deleteSubject: {
1588
+ parameters: {
1589
+ path: {
1590
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
1591
+ };
1592
+ };
1593
+ responses: {
1594
+ /** @description Subject deleted. */
1595
+ 204: {
1596
+ content: never;
1597
+ };
1598
+ 400: components['responses']['BadRequestProblemResponse'];
1599
+ 401: components['responses']['UnauthorizedProblemResponse'];
1600
+ 404: components['responses']['NotFoundProblemResponse'];
1601
+ 501: components['responses']['NotImplementedProblemResponse'];
1602
+ default: components['responses']['UnexpectedProblemResponse'];
1603
+ };
1604
+ };
1605
+ /**
1606
+ * Query portal meter
1607
+ * @description Query meter for consumer portal. This endpoint is publicly exposable to consumers.
1608
+ */
1609
+ queryPortalMeter: {
1610
+ parameters: {
1611
+ query?: {
1612
+ from?: components['parameters']['queryFrom'];
1613
+ to?: components['parameters']['queryTo'];
1614
+ windowSize?: components['parameters']['queryWindowSize'];
1615
+ windowTimeZone?: components['parameters']['queryWindowTimeZone'];
1616
+ filterGroupBy?: components['parameters']['queryFilterGroupBy'];
1617
+ groupBy?: components['parameters']['queryGroupBy'];
1618
+ };
1619
+ path: {
1620
+ /** @description A unique identifier for the meter. */
1621
+ meterSlug: string;
1622
+ };
1623
+ };
1624
+ responses: {
1625
+ /** @description Usage data. */
1626
+ 200: {
1627
+ content: {
1628
+ 'application/json': components['schemas']['MeterQueryResult'];
1629
+ 'text/csv': string;
1630
+ };
1631
+ };
1632
+ 400: components['responses']['BadRequestProblemResponse'];
1633
+ 401: components['responses']['UnauthorizedProblemResponse'];
1634
+ default: components['responses']['UnexpectedProblemResponse'];
1635
+ };
1636
+ };
1637
+ /**
1638
+ * List entitlements
1639
+ * @description List entitlements.
1640
+ */
1641
+ listEntitlements: {
285
1642
  parameters: {
286
- header?: {
287
- "OM-Namespace"?: components["parameters"]["namespaceParam"];
1643
+ query?: {
1644
+ limit?: components['parameters']['queryLimit'];
1645
+ offset?: components['parameters']['queryOffset'];
1646
+ /** @description Order by field */
1647
+ orderBy?: 'createdAt' | 'updatedAt';
1648
+ };
1649
+ };
1650
+ responses: {
1651
+ /** @description List of entitlements. */
1652
+ 200: {
1653
+ content: {
1654
+ 'application/json': components['schemas']['Entitlement'][];
1655
+ };
1656
+ };
1657
+ 401: components['responses']['UnauthorizedProblemResponse'];
1658
+ default: components['responses']['UnexpectedProblemResponse'];
1659
+ };
1660
+ };
1661
+ /**
1662
+ * List features
1663
+ * @description List features.
1664
+ */
1665
+ listFeatures: {
1666
+ parameters: {
1667
+ query?: {
1668
+ limit?: components['parameters']['queryLimit'];
1669
+ offset?: components['parameters']['queryOffset'];
1670
+ /** @description Order by field */
1671
+ orderBy?: 'id' | 'createdAt' | 'updatedAt';
1672
+ /** @description Include archived features. */
1673
+ includeArchived?: boolean;
1674
+ };
1675
+ };
1676
+ responses: {
1677
+ /** @description List of features. */
1678
+ 200: {
1679
+ content: {
1680
+ 'application/json': components['schemas']['Feature'][];
1681
+ };
288
1682
  };
1683
+ 401: components['responses']['UnauthorizedProblemResponse'];
1684
+ default: components['responses']['UnexpectedProblemResponse'];
289
1685
  };
1686
+ };
1687
+ /**
1688
+ * Create feature
1689
+ * @description Creates a feature.
1690
+ */
1691
+ createFeature: {
1692
+ /** @description The feature to create. */
290
1693
  requestBody: {
291
1694
  content: {
292
- "application/json": components["schemas"]["Meter"];
1695
+ 'application/json': components['schemas']['FeatureCreateInputs'];
293
1696
  };
294
1697
  };
295
1698
  responses: {
296
- /** @description Created */
1699
+ /** @description Feature created. */
297
1700
  201: {
298
1701
  content: {
299
- "application/json": components["schemas"]["Meter"];
1702
+ 'application/json': components['schemas']['Feature'];
300
1703
  };
301
1704
  };
302
- 400: components["responses"]["BadRequestProblemResponse"];
303
- 501: components["responses"]["NotImplementedProblemResponse"];
304
- default: components["responses"]["UnexpectedProblemResponse"];
1705
+ 400: components['responses']['BadRequestProblemResponse'];
1706
+ 401: components['responses']['UnauthorizedProblemResponse'];
1707
+ 501: components['responses']['NotImplementedProblemResponse'];
1708
+ default: components['responses']['UnexpectedProblemResponse'];
305
1709
  };
306
1710
  };
307
- /** @description Get meter by slugs */
308
- getMeter: {
1711
+ /**
1712
+ * Get feature
1713
+ * @description Get feature by id.
1714
+ */
1715
+ getFeature: {
309
1716
  parameters: {
310
- header?: {
311
- "OM-Namespace"?: components["parameters"]["namespaceParam"];
1717
+ path: {
1718
+ featureId: components['parameters']['featureId'];
1719
+ };
1720
+ };
1721
+ responses: {
1722
+ /** @description Feature found. */
1723
+ 200: {
1724
+ content: {
1725
+ 'application/json': components['schemas']['Feature'];
1726
+ };
312
1727
  };
1728
+ 401: components['responses']['UnauthorizedProblemResponse'];
1729
+ 404: components['responses']['NotFoundProblemResponse'];
1730
+ default: components['responses']['UnexpectedProblemResponse'];
1731
+ };
1732
+ };
1733
+ /**
1734
+ * Delete feature
1735
+ * @description Delete a feature by key.
1736
+ */
1737
+ deleteFeature: {
1738
+ parameters: {
313
1739
  path: {
314
- meterIdOrSlug: components["parameters"]["meterIdOrSlug"];
1740
+ featureId: components['parameters']['featureId'];
1741
+ };
1742
+ };
1743
+ responses: {
1744
+ /** @description Feature deleted. */
1745
+ 204: {
1746
+ content: never;
1747
+ };
1748
+ 401: components['responses']['UnauthorizedProblemResponse'];
1749
+ 404: components['responses']['NotFoundProblemResponse'];
1750
+ default: components['responses']['UnexpectedProblemResponse'];
1751
+ };
1752
+ };
1753
+ /**
1754
+ * List grants
1755
+ * @description List all grants.
1756
+ */
1757
+ listGrants: {
1758
+ parameters: {
1759
+ query?: {
1760
+ limit?: components['parameters']['queryLimit'];
1761
+ offset?: components['parameters']['queryOffset'];
1762
+ /** @description Order by field */
1763
+ orderBy?: 'id' | 'createdAt' | 'updatedAt';
1764
+ includeDeleted?: components['parameters']['includeDeleted'];
315
1765
  };
316
1766
  };
317
1767
  responses: {
318
- /** @description OK */
1768
+ /** @description List of grants. */
319
1769
  200: {
320
1770
  content: {
321
- "application/json": components["schemas"]["Meter"];
1771
+ 'application/json': components['schemas']['EntitlementGrant'][];
322
1772
  };
323
1773
  };
324
- 404: components["responses"]["NotFoundProblemResponse"];
325
- default: components["responses"]["UnexpectedProblemResponse"];
1774
+ 401: components['responses']['UnauthorizedProblemResponse'];
1775
+ default: components['responses']['UnexpectedProblemResponse'];
326
1776
  };
327
1777
  };
328
- /** @description Delete meter by slug */
329
- deleteMeter: {
1778
+ /**
1779
+ * Delete a grant
1780
+ * @description Void (delete) a grant. A grant can only be deleted if it hasn't been used.
1781
+ */
1782
+ voidGrant: {
1783
+ parameters: {
1784
+ path: {
1785
+ grantId: components['parameters']['grantId'];
1786
+ };
1787
+ };
1788
+ responses: {
1789
+ /** @description Grant has been voided. */
1790
+ 204: {
1791
+ content: never;
1792
+ };
1793
+ 400: components['responses']['BadRequestProblemResponse'];
1794
+ 401: components['responses']['UnauthorizedProblemResponse'];
1795
+ 404: components['responses']['NotFoundProblemResponse'];
1796
+ 409: components['responses']['ConflictProblemResponse'];
1797
+ default: components['responses']['UnexpectedProblemResponse'];
1798
+ };
1799
+ };
1800
+ /**
1801
+ * List entitlements
1802
+ * @description List all entitlements for a subject.
1803
+ */
1804
+ listSubjectEntitlements: {
1805
+ parameters: {
1806
+ query?: {
1807
+ includeDeleted?: components['parameters']['includeDeleted'];
1808
+ };
1809
+ path: {
1810
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
1811
+ };
1812
+ };
1813
+ responses: {
1814
+ /** @description List of entitlements. */
1815
+ 200: {
1816
+ content: {
1817
+ 'application/json': components['schemas']['Entitlement'][];
1818
+ };
1819
+ };
1820
+ 401: components['responses']['UnauthorizedProblemResponse'];
1821
+ default: components['responses']['UnexpectedProblemResponse'];
1822
+ };
1823
+ };
1824
+ /**
1825
+ * Create entitlement
1826
+ * @description Create an entitlement for a subject.
1827
+ */
1828
+ createEntitlement: {
330
1829
  parameters: {
331
- header?: {
332
- "OM-Namespace"?: components["parameters"]["namespaceParam"];
1830
+ path: {
1831
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
1832
+ };
1833
+ };
1834
+ /** @description The entitlement to create. */
1835
+ requestBody: {
1836
+ content: {
1837
+ 'application/json': components['schemas']['EntitlementCreateInputs'];
1838
+ };
1839
+ };
1840
+ responses: {
1841
+ /** @description Entitlement created. */
1842
+ 201: {
1843
+ content: {
1844
+ 'application/json': components['schemas']['Entitlement'];
1845
+ };
1846
+ };
1847
+ 400: components['responses']['BadRequestProblemResponse'];
1848
+ 401: components['responses']['UnauthorizedProblemResponse'];
1849
+ 409: components['responses']['ConflictProblemResponse'];
1850
+ 501: components['responses']['NotImplementedProblemResponse'];
1851
+ default: components['responses']['UnexpectedProblemResponse'];
1852
+ };
1853
+ };
1854
+ /**
1855
+ * Get entitlement
1856
+ * @description Get entitlement by id.
1857
+ */
1858
+ getEntitlement: {
1859
+ parameters: {
1860
+ path: {
1861
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
1862
+ entitlementId: components['parameters']['entitlementId'];
333
1863
  };
1864
+ };
1865
+ responses: {
1866
+ /** @description Entitlement found. */
1867
+ 200: {
1868
+ content: {
1869
+ 'application/json': {
1870
+ type: 'json';
1871
+ } & Omit<components['schemas']['Entitlement'], 'type'> & {
1872
+ /**
1873
+ * Format: date-time
1874
+ * @description The last time usage was reset.
1875
+ * @example 2023-01-01T00:00:00Z
1876
+ */
1877
+ lastReset?: string;
1878
+ };
1879
+ };
1880
+ };
1881
+ 401: components['responses']['UnauthorizedProblemResponse'];
1882
+ 404: components['responses']['NotFoundProblemResponse'];
1883
+ default: components['responses']['UnexpectedProblemResponse'];
1884
+ };
1885
+ };
1886
+ /**
1887
+ * Delete entitlement
1888
+ * @description Delete an entitlement by id.
1889
+ */
1890
+ deleteEntitlement: {
1891
+ parameters: {
334
1892
  path: {
335
- meterIdOrSlug: components["parameters"]["meterIdOrSlug"];
1893
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
1894
+ entitlementId: components['parameters']['entitlementId'];
336
1895
  };
337
1896
  };
338
1897
  responses: {
339
- /** @description No Content */
1898
+ /** @description Entitlement deleted. */
340
1899
  204: {
341
1900
  content: never;
342
1901
  };
343
- 404: components["responses"]["NotFoundProblemResponse"];
344
- 501: components["responses"]["NotImplementedProblemResponse"];
345
- default: components["responses"]["UnexpectedProblemResponse"];
1902
+ 401: components['responses']['UnauthorizedProblemResponse'];
1903
+ 404: components['responses']['NotFoundProblemResponse'];
1904
+ default: components['responses']['UnexpectedProblemResponse'];
1905
+ };
1906
+ };
1907
+ /**
1908
+ * List grants for an entitlement
1909
+ * @description List all grants for an entitlement.
1910
+ */
1911
+ listEntitlementGrants: {
1912
+ parameters: {
1913
+ query?: {
1914
+ includeDeleted?: components['parameters']['includeDeleted'];
1915
+ /** @description Order by field */
1916
+ orderBy?: 'id' | 'createdAt' | 'updatedAt';
1917
+ };
1918
+ path: {
1919
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
1920
+ entitlementId: components['parameters']['entitlementId'];
1921
+ };
1922
+ };
1923
+ responses: {
1924
+ /** @description List of grants. */
1925
+ 200: {
1926
+ content: {
1927
+ 'application/json': components['schemas']['EntitlementGrant'][];
1928
+ };
1929
+ };
1930
+ 401: components['responses']['UnauthorizedProblemResponse'];
1931
+ default: components['responses']['UnexpectedProblemResponse'];
1932
+ };
1933
+ };
1934
+ /**
1935
+ * Create grant
1936
+ * @description Create a grant for an entitlement.
1937
+ */
1938
+ createGrant: {
1939
+ parameters: {
1940
+ path: {
1941
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
1942
+ entitlementId: components['parameters']['entitlementId'];
1943
+ };
1944
+ };
1945
+ /** @description The grant to create. */
1946
+ requestBody: {
1947
+ content: {
1948
+ 'application/json': components['schemas']['EntitlementGrantCreateInput'];
1949
+ };
1950
+ };
1951
+ responses: {
1952
+ /** @description Grant created. */
1953
+ 201: {
1954
+ content: {
1955
+ 'application/json': components['schemas']['EntitlementGrant'];
1956
+ };
1957
+ };
1958
+ 400: components['responses']['BadRequestProblemResponse'];
1959
+ 401: components['responses']['UnauthorizedProblemResponse'];
1960
+ 501: components['responses']['NotImplementedProblemResponse'];
1961
+ default: components['responses']['UnexpectedProblemResponse'];
346
1962
  };
347
1963
  };
348
- /** @description Get meter values */
349
- getMeterValues: {
1964
+ /**
1965
+ * Get the balance of a specific entitlement.
1966
+ * @description Get the balance of a specific entitlement.
1967
+ */
1968
+ getEntitlementValue: {
350
1969
  parameters: {
351
1970
  query?: {
352
- subject?: string;
1971
+ /** @description Point of time to check value: date-time in RFC 3339 format. Defaults to now. */
1972
+ time?: string;
1973
+ };
1974
+ path: {
1975
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
1976
+ entitlementIdOrFeatureKey: components['parameters']['entitlementIdOrFeatureKey'];
1977
+ };
1978
+ };
1979
+ responses: {
1980
+ /** @description The entitlement value. */
1981
+ 200: {
1982
+ content: {
1983
+ 'application/json': components['schemas']['EntitlementValue'];
1984
+ };
1985
+ };
1986
+ 400: components['responses']['BadRequestProblemResponse'];
1987
+ 401: components['responses']['UnauthorizedProblemResponse'];
1988
+ 404: components['responses']['NotFoundProblemResponse'];
1989
+ default: components['responses']['UnexpectedProblemResponse'];
1990
+ };
1991
+ };
1992
+ /**
1993
+ * Get the balance history of a specific entitlement.
1994
+ * @description Get the balance history of a specific entitlement.
1995
+ *
1996
+ * The windows are inclusive at their start and exclusive at their end.
1997
+ * The last window may be smaller than the window size and is inclusive at both ends.
1998
+ */
1999
+ getEntitlementHistory: {
2000
+ parameters: {
2001
+ query: {
353
2002
  /**
354
- * @description Start date-time in RFC 3339 format.
355
- * Must be aligned with the window size.
356
- * Inclusive.
2003
+ * @description Start of time range to query entitlement: date-time in RFC 3339 format. Defaults to
2004
+ * the last reset.
2005
+ * Gets truncated to the granularity of the underlying meter.
357
2006
  */
358
2007
  from?: string;
359
2008
  /**
360
- * @description End date-time in RFC 3339 format.
361
- * Must be aligned with the window size.
362
- * Inclusive.
2009
+ * @description End of time range to query entitlement: date-time in RFC 3339 format. Defaults to now.
2010
+ * If not now then gets truncated to the granularity of the underlying meter.
363
2011
  */
364
2012
  to?: string;
365
- /** @description If not specified, a single usage aggregate will be returned for the entirety of the specified period for each subject and group. */
366
- windowSize?: components["schemas"]["WindowSize"];
367
- /**
368
- * @description If not specified, OpenMeter will use the default aggregation type.
369
- * As OpenMeter stores aggregates defined by meter config, passing a different aggregate can lead to inaccurate results.
370
- * For example getting the MIN of SUMs.
371
- */
372
- aggregation?: components["schemas"]["MeterAggregation"];
373
- /** @description If not specified a single aggregate will be returned for each subject and time window. */
374
- groupBy?: string;
375
- };
376
- header?: {
377
- "OM-Namespace"?: components["parameters"]["namespaceParam"];
2013
+ /** @description Size of the time window to group the history by. Cannot be shorter than meter granularity. */
2014
+ windowSize: 'MINUTE' | 'HOUR' | 'DAY';
2015
+ windowTimeZone?: components['parameters']['queryWindowTimeZone'];
378
2016
  };
379
2017
  path: {
380
- meterIdOrSlug: components["parameters"]["meterIdOrSlug"];
2018
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
2019
+ entitlementId: components['parameters']['entitlementId'];
381
2020
  };
382
2021
  };
383
2022
  responses: {
384
- /** @description OK */
2023
+ /** @description Entitlement balance history. If windowsize is specified then the history is grouped by the window size. */
385
2024
  200: {
386
2025
  content: {
387
- "application/json": {
388
- windowSize?: components["schemas"]["WindowSize"];
389
- data: components["schemas"]["MeterValue"][];
390
- };
2026
+ 'application/json': components['schemas']['WindowedBalanceHistory'];
391
2027
  };
392
2028
  };
393
- 400: components["responses"]["BadRequestProblemResponse"];
394
- default: components["responses"]["UnexpectedProblemResponse"];
2029
+ 400: components['responses']['BadRequestProblemResponse'];
2030
+ 401: components['responses']['UnauthorizedProblemResponse'];
2031
+ 404: components['responses']['NotFoundProblemResponse'];
2032
+ default: components['responses']['UnexpectedProblemResponse'];
395
2033
  };
396
2034
  };
397
- /** @description Create namespace */
398
- createNamespace: {
2035
+ /**
2036
+ * Reset entitlement
2037
+ * @description Reset the entitlement usage and start a new period. Grants that can be are rolled over.
2038
+ */
2039
+ resetEntitlementUsage: {
2040
+ parameters: {
2041
+ path: {
2042
+ subjectIdOrKey: components['parameters']['subjectIdOrKey'];
2043
+ entitlementId: components['parameters']['entitlementId'];
2044
+ };
2045
+ };
399
2046
  requestBody: {
400
2047
  content: {
401
- "application/json": components["schemas"]["Namespace"];
2048
+ 'application/json': {
2049
+ /**
2050
+ * Format: date-time
2051
+ * @description The time at which the reset takes effect, defaults to now.
2052
+ * The reset cannot be in the future.
2053
+ * The provided value is truncated to the granularity of the underlying meter.
2054
+ *
2055
+ * @example 2023-01-01T00:00:00Z
2056
+ */
2057
+ effectiveAt?: string;
2058
+ /**
2059
+ * @description Should the reset retain the usage period anchor.
2060
+ * If true, the usage period anchor is retained.
2061
+ * If false, the usage period anchor is reset to the effectiveAt time.
2062
+ */
2063
+ retainAnchor?: boolean;
2064
+ };
402
2065
  };
403
2066
  };
404
2067
  responses: {
405
- /** @description Created */
406
- 201: {
407
- content: {
408
- "application/json": components["schemas"]["Namespace"];
409
- };
2068
+ /** @description Entitlement reset. */
2069
+ 204: {
2070
+ content: never;
410
2071
  };
411
- default: components["responses"]["UnexpectedProblemResponse"];
2072
+ 400: components['responses']['BadRequestProblemResponse'];
2073
+ 401: components['responses']['UnauthorizedProblemResponse'];
2074
+ 404: components['responses']['NotFoundProblemResponse'];
2075
+ default: components['responses']['UnexpectedProblemResponse'];
412
2076
  };
413
2077
  };
414
2078
  }